Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Apache Airflow Pool Management

From Leeroopedia


Knowledge Sources
Domains Resource_Management, ORM
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for managing task concurrency pools provided by the Airflow Pool model.

Description

The Pool class is a SQLAlchemy model representing a resource pool with a fixed number of slots. It provides CRUD operations for managing pools and methods for querying slot availability. The default_pool is automatically created and used by tasks that don't specify a pool.

Usage

Create pools via the Airflow UI, CLI, or API when you need to limit concurrent access to shared resources. Reference pools in task definitions via the pool parameter.

Code Reference

Source Location

  • Repository: Apache Airflow
  • File: airflow-core/src/airflow/models/pool.py
  • Lines: L75-382

Signature

class Pool(Base):
    __tablename__ = "slot_pool"

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    pool: Mapped[str] = mapped_column(String(256), unique=True)
    slots: Mapped[int] = mapped_column(Integer, default=0)  # -1 for infinite
    description: Mapped[str | None] = mapped_column(Text, nullable=True)
    include_deferred: Mapped[bool] = mapped_column(Boolean, nullable=False)
    team_name: Mapped[str | None] = mapped_column(String(50), nullable=True)

    DEFAULT_POOL_NAME = "default_pool"

    @staticmethod
    def create_or_update_pool(
        name: str,
        slots: int,
        description: str,
        include_deferred: bool,
        session: Session,
    ) -> "Pool": ...

Import

from airflow.models.pool import Pool

I/O Contract

Inputs

Name Type Required Description
pool (name) str Yes Unique pool identifier (max 256 chars)
slots int Yes Concurrency limit (-1 for unlimited)
description str No Pool description
include_deferred bool Yes Whether deferred tasks count against slots

Outputs

Name Type Description
Pool object Pool Created or updated pool record
Slot allocation int Available/occupied/queued/deferred/scheduled_or_active slot counts

Usage Examples

Pool Management

# Create a pool via CLI
airflow pools set my_pool 5 "Database connection pool"

# List pools
airflow pools list
# Reference pool in task
@task(pool="my_pool", pool_slots=2)
def heavy_db_task():
    ...

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment