Bootstep consuming events from other workers.
This keeps the logical clock value up to date.
Attributes
| Attribute | Type | Description |
|---|
| label | string = Gossip | Internal identifier used for logging and step tracking within the bootstep graph. |
| requires | tuple = (Mingle,) | A tuple of bootstep classes that must be initialized before the Gossip step can start. |
| compatible_transports | set = {'amqp', 'redis'} | A set of broker transport names that support the gossip protocol requirements. |
Constructor
Signature
def Gossip(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer),
without_gossip: boolean = False,
interval: float = 5.0,
heartbeat_interval: float = 2.0,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance associated with this bootstep. |
| without_gossip | boolean = False | Flag to manually disable the gossip service. |
| interval | float = 5.0 | The interval in seconds for periodic gossip checks. |
| heartbeat_interval | float = 2.0 | The interval in seconds for heartbeat events. |
| **kwargs | dict | Additional keyword arguments passed to the parent class constructor. |
Methods
compatible_transport()
@classmethod
def compatible_transport(
app: [Celery](../../../app/base/celery.md?sid=celery_app_base_celery)
) - > boolean
Checks if the current application transport is supported by the Gossip bootstep.
Parameters
| Name | Type | Description |
|---|
| app | [Celery](../../../app/base/celery.md?sid=celery_app_base_celery) | The Celery application instance used to inspect the connection transport |
Returns
| Type | Description |
|---|
boolean | True if the transport driver type is 'amqp' or 'redis', otherwise False |
election()
@classmethod
def election(
id: string,
topic: string,
action: any
) - > null
Initiates a leader election process across the cluster for a specific topic.
Parameters
| Name | Type | Description |
|---|
| id | string | The unique identifier for this specific election request |
| topic | string | The category of the election, such as 'task', which determines the handler to execute |
| action | any | The specific payload or task signature to be executed by the election winner |
Returns
call_task()
@classmethod
def call_task(
task: string|dict
) - > null
Executes a task signature asynchronously as a result of winning an election.
Parameters
| Name | Type | Description |
|---|
| task | `string | dict` |
Returns
on_elect()
@classmethod
def on_elect(
event: dict
) - > null
Handles incoming election requests from other nodes and sends an acknowledgment.
Parameters
| Name | Type | Description |
|---|
| event | dict | The election event payload containing clock, hostname, and election metadata |
Returns
start()
@classmethod
def start(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer)
) - > null
Starts the Gossip bootstep and initializes the event dispatcher.
Parameters
| Name | Type | Description |
|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance providing the event dispatcher |
Returns
on_elect_ack()
@classmethod
def on_elect_ack(
event: dict
) - > null
Processes election acknowledgments and determines the winner once all nodes have replied.
Parameters
| Name | Type | Description |
|---|
| event | dict | The acknowledgment event containing the responding node's hostname and election ID |
Returns
on_node_join()
@classmethod
def on_node_join(
worker: [Worker](../../../events/state/worker.md?sid=celery_events_state_worker)
) - > null
Triggers registered callbacks when a new worker node is detected in the cluster.
Parameters
| Name | Type | Description |
|---|
| worker | [Worker](../../../events/state/worker.md?sid=celery_events_state_worker) | The worker state object representing the node that joined |
Returns
on_node_leave()
@classmethod
def on_node_leave(
worker: [Worker](../../../events/state/worker.md?sid=celery_events_state_worker)
) - > null
Triggers registered callbacks when a worker node gracefully leaves the cluster.
Parameters
| Name | Type | Description |
|---|
| worker | [Worker](../../../events/state/worker.md?sid=celery_events_state_worker) | The worker state object representing the node that left |
Returns
on_node_lost()
@classmethod
def on_node_lost(
worker: [Worker](../../../events/state/worker.md?sid=celery_events_state_worker)
) - > null
Triggers registered callbacks when a worker node is considered lost due to missed heartbeats.
Parameters
| Name | Type | Description |
|---|
| worker | [Worker](../../../events/state/worker.md?sid=celery_events_state_worker) | The worker state object representing the node that was lost |
Returns
register_timer()
@classmethod
def register_timer() - > null
Schedules the periodic cleanup task to run at the configured interval.
Returns
periodic()
@classmethod
def periodic() - > null
Inspects the state of all known workers and removes those that are no longer alive.
Returns
get_consumers()
@classmethod
def get_consumers(
channel: Channel
) - > list
Returns a list of AMQP consumers configured to listen for worker events.
Parameters
| Name | Type | Description |
|---|
| channel | Channel | The AMQP channel used to create the consumer |
Returns
| Type | Description |
|---|
list | A list containing a Kombu Consumer configured for worker event patterns |
on_message()
@classmethod
def on_message(
prepare: callable,
message: Message
) - > any
Dispatches incoming messages to specific event handlers or updates the internal worker state.
Parameters
| Name | Type | Description |
|---|
| prepare | callable | A function used to deserialize and prepare the message payload |
| message | Message | The raw message object received from the broker |
Returns
| Type | Description |
|---|
any | The result of the specific event handler, or null if processed as a state update |