Celery check if queue is executing

celery, django-celery, multithreading, python

Solution

If you just want to inspect the queue, you do this from command line itself.

 from celery.task.control import inspect
 i = inspect('scrapper_start')
 i.active()  #  get a list of active tasks

In addition to checking which are currently executing, you can also do the following.

 i.registered() # get a list of tasks registered
 i.scheduled # get a list of tasks waiting
 i.reserved() #tasks that has been received, but waiting to be executed

This command line inspection is good if you want to check once in a while.

For some reason, if you want to monitor them continuously, you can use Flower which provides a beautiful interface to monitor workers.

Problem

I have to spawn celery tasks, which have to have some namespace (for example user id). So I'm spawn it by ``` scrapper_start.apply_async((request.user.id,), queue=account.Account_username) app.control.add_consumer(account.Account_username, reply=True) ``` And tasks spawns recursively, from other task. Now I have to check, if tasks of queue are executing. Tried to check list length in redis, it return true number before celery start executing. How to solve this problem. I need only to check, if queue or consumer is executing or already empty. Thanks

Original source