Hub
Worker starts the event loop.
Attributes
| Attribute | Type | Description |
|---|---|---|
| requires | tuple = (Timer,) | A tuple containing the bootstep classes that must be initialized before the Hub can start, specifically requiring the Timer step. |
Constructor
Signature
def Hub(
w: Any,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| w | Any | The worker instance associated with this hub. |
| **kwargs | dict | Additional keyword arguments passed to the parent constructor. |
Methods
include_if()
@classmethod
def include_if(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > bool
Determines if the event loop should be included based on the worker's configuration.
Parameters
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance being initialized to check for event loop requirements. |
Returns
| Type | Description |
|---|---|
bool | True if the worker is configured to use an event loop, False otherwise. |
create()
@classmethod
def create(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > [Hub](hub.md?sid=celery_worker_components_hub)
Initializes the event loop for the worker and applies necessary thread primitive patches.
Parameters
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance where the event loop (hub) will be instantiated and assigned. |
Returns
| Type | Description |
|---|---|
[Hub](hub.md?sid=celery_worker_components_hub) | The current Hub instance after the event loop has been assigned to the worker. |
start()
@classmethod
def start(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > null
Ensures the kombu hub's poller is initialized before the event loop starts.
Parameters
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance containing the hub whose poller needs initialization. |
Returns
| Type | Description |
|---|---|
null |
stop()
@classmethod
def stop(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > null
Closes the worker's event loop to release resources during a graceful shutdown.
Parameters
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance whose hub should be closed. |
Returns
| Type | Description |
|---|---|
null |
terminate()
@classmethod
def terminate(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker)
) - > null
Closes the worker's event loop immediately during a process termination.
Parameters
| Name | Type | Description |
|---|---|---|
| w | [Worker](../../events/state/worker.md?sid=celery_events_state_worker) | The worker instance whose hub should be closed. |
Returns
| Type | Description |
|---|---|
null |