Skip to main content

WorkerComponent

Bootstep that starts the autoscaler thread/timer in the worker.

Attributes

AttributeTypeDescription
labelstring = AutoscalerInternal identifier used for logging and reporting the status of the autoscaler bootstep.
conditionalboolean = TrueFlag indicating that the step is only enabled if specific conditions are met during worker startup.
requirestuple = (Pool,)Sequence of other bootsteps or components that must be initialized before the autoscaler can start.

Constructor

Signature

def WorkerComponent(
w: Any,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
wAnyThe worker instance being initialized.
**kwargsdictAdditional keyword arguments.

Signature

def WorkerComponent(
w: [Worker](../../events/state/worker.md?sid=celery_events_state_worker),
kwargs: dict
) - > null

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance being initialized.
kwargsdictAdditional keyword arguments passed during bootstep initialization.

Methods


create()

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

Instantiates the autoscaler using the worker's configuration and assigns it to the worker instance.

Parameters

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

Returns

TypeDescription
`Autoscalernull`

register_with_event_loop()

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

Integrates the autoscaler with the worker's event loop by attaching scaling logic to task messages and periodic keepalive checks.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance containing the consumer and autoscaler.
hub[Hub](../components/hub.md?sid=celery_worker_components_hub)The event loop hub used to schedule repeated scaling checks.

Returns

TypeDescription
null

info()

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

Return Autoscaler info.

Parameters

NameTypeDescription
w[Worker](../../events/state/worker.md?sid=celery_events_state_worker)The worker instance from which to retrieve autoscaler information.

Returns

TypeDescription
dictA dictionary containing the current status and metadata of the worker's autoscaler.