Marcin Marcin - 3 months ago 26x
Python Question

How to check task status in Celery?

How does one check whether a task is running in celery (specifically, I'm using celery-django)?

I've read the documentation, and I've googled, but I can't see a call like:

my_example_task.state() == RUNNING

My use-case is that I have an external (java) service for transcoding. When I send a document to be transcoded, I want to check if the task that runs that service is running, and if not, to (re)start it.

I'm using the current stable versions - 2.4, I believe.


Every Task object has a .request property, which contains it AsyncRequest object. Accordingly, the following line gives the state of a Task task: