Task States¶
Constants and sets for task state management.
State constants¶
| Constant | Value | Description |
|---|---|---|
PENDING |
"PENDING" |
Task is waiting for execution or unknown |
RECEIVED |
"RECEIVED" |
Task received by a worker |
STARTED |
"STARTED" |
Task has been started |
SUCCESS |
"SUCCESS" |
Task executed successfully |
FAILURE |
"FAILURE" |
Task execution failed |
REVOKED |
"REVOKED" |
Task has been revoked |
RETRY |
"RETRY" |
Task is being retried |
REJECTED |
"REJECTED" |
Task was rejected by a worker |
IGNORED |
"IGNORED" |
Task result was ignored |
State sets¶
| Set | States | Description |
|---|---|---|
READY_STATES |
SUCCESS, FAILURE, REVOKED | Task has finished executing |
UNREADY_STATES |
PENDING, RECEIVED, STARTED, RETRY, REJECTED | Task is not yet done |
EXCEPTION_STATES |
FAILURE, RETRY, REVOKED | Task raised an exception |
PROPAGATE_STATES |
FAILURE, REVOKED | Exceptions that should propagate to caller |
Module reference¶
Built-in task states.
.. _states:
States¶
See :ref:task-states.
.. _statesets:
Sets¶
.. state:: READY_STATES
READY_STATES ~~~~~~~~~~~~
Set of states meaning the task result is ready (has been executed).
.. state:: UNREADY_STATES
UNREADY_STATES ~~~~~~~~~~~~~~
Set of states meaning the task result is not ready (hasn't been executed).
.. state:: EXCEPTION_STATES
EXCEPTION_STATES ~~~~~~~~~~~~~~~~
Set of states meaning the task returned an exception.
.. state:: PROPAGATE_STATES
PROPAGATE_STATES ~~~~~~~~~~~~~~~~
Set of exception states that should propagate exceptions to the user.
.. state:: ALL_STATES
ALL_STATES ~~~~~~~~~~
Set of all possible states.
Misc¶
UNREADY_STATES
module-attribute
¶
ALL_STATES
module-attribute
¶
state ¶
Bases: str
Task state.
State is a subclass of :class:str, implementing comparison
methods adhering to state precedence rules::
>>> from celery.states import state, PENDING, SUCCESS
>>> state(PENDING) < state(SUCCESS)
True
Any custom state is considered to be lower than :state:FAILURE and
:state:SUCCESS, but higher than any of the other built-in states::
>>> state('PROGRESS') > state(STARTED)
True
>>> state('PROGRESS') > state('SUCCESS')
False
precedence ¶
Get the precedence index for state.
Lower index means higher precedence.