|
@@ -3,7 +3,7 @@
|
|
|
celery.states
|
|
|
=============
|
|
|
|
|
|
-Built-in Task States.
|
|
|
+Built-in task states.
|
|
|
|
|
|
.. _states:
|
|
|
|
|
@@ -12,6 +12,8 @@ States
|
|
|
|
|
|
See :ref:`task-states`.
|
|
|
|
|
|
+.. _statesets:
|
|
|
+
|
|
|
Sets
|
|
|
----
|
|
|
|
|
@@ -84,22 +86,38 @@ def precedence(state):
|
|
|
|
|
|
class state(str):
|
|
|
"""State is a subclass of :class:`str`, implementing comparison
|
|
|
- methods adhering to state precedence rules."""
|
|
|
+ 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
|
|
|
+
|
|
|
+ """
|
|
|
|
|
|
- def compare(self, other, fun, default=False):
|
|
|
+ def compare(self, other, fun):
|
|
|
return fun(precedence(self), precedence(other))
|
|
|
|
|
|
def __gt__(self, other):
|
|
|
- return self.compare(other, lambda a, b: a < b, True)
|
|
|
+ return self.compare(other, lambda a, b: a < b)
|
|
|
|
|
|
def __ge__(self, other):
|
|
|
- return self.compare(other, lambda a, b: a <= b, True)
|
|
|
+ return self.compare(other, lambda a, b: a <= b)
|
|
|
|
|
|
def __lt__(self, other):
|
|
|
- return self.compare(other, lambda a, b: a > b, False)
|
|
|
+ return self.compare(other, lambda a, b: a > b)
|
|
|
|
|
|
def __le__(self, other):
|
|
|
- return self.compare(other, lambda a, b: a >= b, False)
|
|
|
+ return self.compare(other, lambda a, b: a >= b)
|
|
|
|
|
|
PENDING = 'PENDING'
|
|
|
RECEIVED = 'RECEIVED'
|