airflow.models.pool

Module Contents

Classes

PoolStats

Dictionary containing Pool Stats

Pool

the class to get Pool info.

class airflow.models.pool.PoolStats[source]

Bases: airflow.typing_compat.TypedDict

Dictionary containing Pool Stats

total :int[source]
running :int[source]
queued :int[source]
open :int[source]
class airflow.models.pool.Pool[source]

Bases: airflow.models.base.Base

the class to get Pool info.

__tablename__ = slot_pool[source]
id[source]
pool[source]
slots[source]
description[source]
DEFAULT_POOL_NAME = default_pool[source]
__repr__(self)[source]

Return repr(self).

static get_pools(session: sqlalchemy.orm.session.Session = NEW_SESSION)[source]

Get all pools.

static get_pool(pool_name: str, session: sqlalchemy.orm.session.Session = NEW_SESSION)[source]

Get the Pool with specific pool name from the Pools.

Parameters
  • pool_name – The pool name of the Pool to get.

  • session – SQLAlchemy ORM Session

Returns

the pool object

static get_default_pool(session: sqlalchemy.orm.session.Session = NEW_SESSION)[source]

Get the Pool of the default_pool from the Pools.

Parameters

session – SQLAlchemy ORM Session

Returns

the pool object

static create_or_update_pool(name: str, slots: int, description: str, session: sqlalchemy.orm.session.Session = NEW_SESSION)[source]

Create a pool with given parameters or update it if it already exists.

static delete_pool(name: str, session: sqlalchemy.orm.session.Session = NEW_SESSION)[source]

Delete pool by a given name.

static slots_stats(lock_rows: bool = False, session: sqlalchemy.orm.session.Session = NEW_SESSION) Dict[str, PoolStats][source]

Get Pool stats (Number of Running, Queued, Open & Total tasks)

If lock_rows is True, and the database engine in use supports the NOWAIT syntax, then a non-blocking lock will be attempted – if the lock is not available then SQLAlchemy will throw an OperationalError.

Parameters
  • lock_rows – Should we attempt to obtain a row-level lock on all the Pool rows returns

  • session – SQLAlchemy ORM Session

to_json(self)[source]

Get the Pool in a json structure

Returns

the pool object in json format

occupied_slots(self, session: sqlalchemy.orm.session.Session)[source]

Get the number of slots used by running/queued tasks at the moment.

Parameters

session – SQLAlchemy ORM Session

Returns

the used number of slots

running_slots(self, session: sqlalchemy.orm.session.Session)[source]

Get the number of slots used by running tasks at the moment.

Parameters

session – SQLAlchemy ORM Session

Returns

the used number of slots

queued_slots(self, session: sqlalchemy.orm.session.Session)[source]

Get the number of slots used by queued tasks at the moment.

Parameters

session – SQLAlchemy ORM Session

Returns

the used number of slots

open_slots(self, session: sqlalchemy.orm.session.Session = NEW_SESSION) float[source]

Get the number of slots open at the moment.

Parameters

session – SQLAlchemy ORM Session

Returns

the number of slots

Was this entry helpful?