I store the task_id
from an celery.result.AsyncResult
in a database and relate it to the item that the task affects. This allows me to perform a query to retrieve all the task_id
s of tasks that relate to a specific item.
So after retrieving the task_id
from the database, how do I go about retrieving information about the task's state/result/etc?
In Celery, a result back end is a place where, when you call a Celery task with a return statement, the task results are stored. Choosing the right results back end can potentially save you hours of pain later.
The "shared_task" decorator allows creation of Celery tasks for reusable apps as it doesn't need the instance of the Celery app. It is also easier way to define a task as you don't need to import the Celery app instance.
From the Celery FAQ:
result = MyTask.AsyncResult(task_id) result.get()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With