Skip to main content

Pool

Bootstep managing the worker pool. Describes how to initialize the worker pool, and starts and stops the pool during worker start-up/shutdown.

Attributes

AttributeTypeDescription
requirestuple = (Hub,)A tuple containing the bootstep classes that must be initialized before this pool bootstep can start, specifically requiring the Hub.

Constructor

Signature

def Pool(
w: Any,
autoscale: Union[str, list, None] = None,
**kwargs: dict
)

Parameters

NameTypeDescription
wAnyThe worker instance being initialized.
autoscaleUnion[str, list, None] = NoneOptional autoscaling settings, either as a comma-separated string or a list of [max, min].
**kwargsdictAdditional keyword arguments passed to the parent class constructor.

Methods


close()

@classmethod
def close(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > null

Closes the worker pool gracefully, allowing existing tasks to complete before shutting down.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance containing the pool to be closed.

Returns

TypeDescription
nullnull

terminate()

@classmethod
def terminate(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > null

Terminates the worker pool immediately, forcing all active tasks to stop without waiting for completion.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance containing the pool to be terminated.

Returns

TypeDescription
nullnull

create()

@classmethod
def create(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > celery.concurrency.base.BasePool

Initializes and configures the worker pool instance based on the worker's concurrency settings and environment.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance for which the pool is being created and attached.

Returns

TypeDescription
celery.concurrency.base.BasePoolThe instantiated pool object configured for the current worker environment.

info()

@classmethod
def info(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > dict

Retrieves runtime information and statistics from the active worker pool.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance whose pool information is being queried.

Returns

TypeDescription
dictA dictionary containing the 'pool' key with status details or 'N/A' if no pool exists.

register_with_event_loop()

@classmethod
def register_with_event_loop(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker),
hub: kombu.asynchronous.Hub
) - > null

Integrates the worker pool with the asynchronous I/O hub to handle non-blocking operations.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance containing the pool to register.
hubkombu.asynchronous.HubThe event loop hub used for coordinating asynchronous I/O events.

Returns

TypeDescription
nullnull