This document describes the current stable version of Celery (4.2). For development docs, go here.


Internal worker state (global).

This includes the currently active and reserved tasks, statistics, and revoked tasks.

celery.worker.state.SOFTWARE_INFO = {u'sw_ident': u'py-celery', u'sw_sys': 'Linux', u'sw_ver': u'4.2.0'}

Worker software/platform information.

celery.worker.state.reserved_requests = <_weakrefset.WeakSet object>

set of all reserved Request’s.

celery.worker.state.active_requests = <_weakrefset.WeakSet object>

set of currently active Request’s.

celery.worker.state.total_count = {}

count of tasks accepted by the worker, sorted by type.

celery.worker.state.revoked = <LimitedSet(0): maxlen=50000, expires=10800, minlen=0>

the list of currently revoked tasks. Persistent if statedb set.

celery.worker.state.task_reserved(request, add_request=<method-wrapper '__setitem__' of dict object>, add_reserved_request=<bound method WeakSet.add of <_weakrefset.WeakSet object>>)[source]

Update global state when a task has been reserved.


Shutdown if flags have been set.

celery.worker.state.task_accepted(request, _all_total_count=[0], add_active_request=<bound method WeakSet.add of <_weakrefset.WeakSet object>>, add_to_total_count=<bound method Counter.update of Counter()>)[source]

Update global state when a task has been accepted.

celery.worker.state.task_ready(request, remove_request=<built-in method pop of dict object>, discard_active_request=<bound method WeakSet.discard of <_weakrefset.WeakSet object>>, discard_reserved_request=<bound method WeakSet.discard of <_weakrefset.WeakSet object>>)[source]

Update global state when a task is ready.

class celery.worker.state.Persistent(state, filename, clock=None)[source]

Stores worker state between restarts.

This is the persistent data stored by the worker when celery worker --statedb is enabled.

Currently only stores revoked task id’s.


compress(string[, level]) – Returned compressed string.

Optional arg level is the compression level, in 0-9.


decompress(string[, wbits[, bufsize]]) – Return decompressed string.

Optional arg wbits indicates the window buffer size and container format. Optional arg bufsize is the initial output buffer size.

protocol = 2
storage = <module 'shelve' from '/usr/lib/python2.7/shelve.pyc'>