Skip to main content

Hub

Worker starts the event loop.

Attributes

AttributeTypeDescription
requirestuple = (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

NameTypeDescription
wAnyThe worker instance associated with this hub.
**kwargsdictAdditional 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

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance being initialized to check for event loop requirements.

Returns

TypeDescription
boolTrue 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

NameTypeDescription
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

TypeDescription
[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

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance containing the hub whose poller needs initialization.

Returns

TypeDescription
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

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance whose hub should be closed.

Returns

TypeDescription
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

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance whose hub should be closed.

Returns

TypeDescription
null