Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve a task result object, given a `task_id` in Celery

Tags:

python

celery

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_ids 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?

like image 636
bradley.ayers Avatar asked Apr 04 '11 21:04

bradley.ayers


People also ask

Where are Celery tasks stored?

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.

What is Shared_task in Celery?

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.


1 Answers

From the Celery FAQ:

result = MyTask.AsyncResult(task_id) result.get() 
like image 185
miles82 Avatar answered Sep 19 '22 00:09

miles82