Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery check if queue is executing

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

like image 252
Vadym Holoveichuk Avatar asked Oct 15 '25 16:10

Vadym Holoveichuk


1 Answers

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. enter image description here

like image 88
Pandikunta Anand Reddy Avatar answered Oct 19 '25 02:10

Pandikunta Anand Reddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!