Given some data from the queue, deserializes it into a Task instance.
The data must be similar in format to what comes from Task.serialize (a JSON-serialized dictionary). Required keys are task_id, retries & async.
Parameters: | data (string) – A JSON-serialized string of the task data |
---|---|
Returns: | A populated task |
Return type: | A Task instance |
Runs the task.
This fires the on_start hook function first (if present), passing the task itself.
Then it runs the target function supplied via Task.to_call with its arguments & stores the result.
If the target function succeeded, the on_success hook function is called, passing both the task & the result to it.
If the target function failed (threw an exception), the on_error hook function is called, passing both the task & the exception to it. Then the exception is re-raised.
Finally, the result is returned.
Serializes the Task data for storing in the queue.
All data must be JSON-serializable in order to be stored properly.
Returns: | A JSON strong of the task data. |
---|
Sets the function & its arguments to be called when the task is processed.
Ex:
task.to_call(my_function, 1, 'c', another=True)
Parameters: |
|
---|
Sets the task’s status as “failed”.
Useful for the on_start/on_success/on_failed hook methods for figuring out what the status of the task is.
Sets the task’s status as “success”.
Useful for the on_start/on_success/on_failed hook methods for figuring out what the status of the task is.
Sets the task’s status as “waiting”.
Useful for the on_start/on_success/on_failed hook methods for figuring out what the status of the task is.