This document describes Celery 3.1. For development docs,
go here.
celery.events.state
This module implements a datastructure used to keep
track of the state of a cluster of workers and the tasks
it is working on (by consuming events).
For every event consumed the state is updated,
so the state represents the state of the cluster
at the time of the last event.
Snapshots (celery.events.snapshot) can be used to
take “pictures” of this state at regular intervals
to e.g. store that in a database.
-
class celery.events.state.Worker(**fields)[source]
Worker State.
-
alive[source]
-
expire_window = 200
-
heartbeat_expires[source]
-
heartbeat_max = 4
-
id[source]
-
on_heartbeat(timestamp=None, local_received=None, **kwargs)[source]
Callback for the worker-heartbeat event.
-
on_offline(**kwargs)[source]
Callback for the worker-offline event.
-
on_online(timestamp=None, local_received=None, **kwargs)[source]
Callback for the worker-online event.
-
pid = None
-
status_string[source]
-
update_heartbeat(received, timestamp)[source]
-
class celery.events.state.Task(**fields)[source]
Task State.
-
info(fields=None, extra=[])[source]
Information about this task suitable for on-screen display.
-
merge(state, timestamp, fields)[source]
Merge with out of order event.
-
merge_rules = {'RECEIVED': ('name', 'args', 'kwargs', 'retries', 'eta', 'expires')}
How to merge out of order events.
Disorder is detected by logical ordering (e.g. task-received
must have happened before a task-failed event).
A merge rule consists of a state and a list of fields to keep from
that state. (RECEIVED, ('name', 'args'), means the name and args
fields are always taken from the RECEIVED state, and any values for
these fields received before or after is simply ignored.
-
on_failed(timestamp=None, **fields)[source]
Callback for the task-failed event.
-
on_received(timestamp=None, **fields)[source]
Callback for the task-received event.
-
on_retried(timestamp=None, **fields)[source]
Callback for the task-retried event.
-
on_revoked(timestamp=None, **fields)[source]
Callback for the task-revoked event.
-
on_sent(timestamp=None, **fields)[source]
Callback for the task-sent event.
-
on_started(timestamp=None, **fields)[source]
Callback for the task-started event.
-
on_succeeded(timestamp=None, **fields)[source]
Callback for the task-succeeded event.
-
on_unknown_event(shortype, timestamp=None, **fields)[source]
-
ready[source]
-
update(state, timestamp, fields, _state=<class 'celery.states.state'>)[source]
Update state from new event.
Parameters: |
- state – State from event.
- timestamp – Timestamp from event.
- fields – Event data.
|
-
class celery.events.state.State(callback=None, workers=None, tasks=None, taskheap=None, max_workers_in_memory=5000, max_tasks_in_memory=10000)[source]
Records clusters state.
-
alive_workers()[source]
Return a list of (seemingly) alive workers.
-
clear(ready=True)[source]
-
clear_tasks(ready=True)[source]
-
event(event)[source]
-
event_count = 0
-
freeze_while(fun, *args, **kwargs)[source]
-
get_or_create_task(uuid)[source]
Get or create task by uuid.
-
get_or_create_worker(hostname, **kwargs)[source]
Get or create worker by hostname.
Return tuple of (worker, was_created).
-
itertasks(limit=None)[source]
-
task_count = 0
-
task_event(type, fields, timetuple=<class 'kombu.clocks.timetuple'>)[source]
Process task event.
-
task_types()[source]
Return a list of all seen task types.
-
tasks_by_time(limit=None)[source]
Generator giving tasks ordered by time,
in (uuid, Task) tuples.
-
tasks_by_timestamp(limit=None)
Generator giving tasks ordered by time,
in (uuid, Task) tuples.
-
tasks_by_type(name, limit=None)[source]
Get all tasks by type.
Return a list of (uuid, Task) tuples.
-
tasks_by_worker(hostname, limit=None)[source]
Get all tasks by worker.
-
worker_event(type, fields)[source]
Process worker event.
-
celery.events.state.heartbeat_expires(timestamp, freq=60, expire_window=200)[source]