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
| Attribute | Type | Description |
|---|---|---|
| requires | tuple = (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
| Name | Type | Description |
|---|---|---|
| w | Any | The worker instance being initialized. |
| autoscale | Union[str, list, None] = None | Optional autoscaling settings, either as a comma-separated string or a list of [max, min]. |
| **kwargs | dict | Additional 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
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance containing the pool to be closed. |
Returns
| Type | Description |
|---|---|
null | null |
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
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance containing the pool to be terminated. |
Returns
| Type | Description |
|---|---|
null | null |
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
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance for which the pool is being created and attached. |
Returns
| Type | Description |
|---|---|
celery.concurrency.base.BasePool | The 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
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance whose pool information is being queried. |
Returns
| Type | Description |
|---|---|
dict | A 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
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance containing the pool to register. |
| hub | kombu.asynchronous.Hub | The event loop hub used for coordinating asynchronous I/O events. |
Returns
| Type | Description |
|---|---|
null | null |