Does celery support returning pending tasks number before given task id?
For example, without celery worker started, I push task1, task2, task3, all the three are pending, now, what I wanna is, if I give task3, it tells me there are 2 pending tasks before 3.
I use celery celery 4.1, rabbitmq 3.5.4 as broker, and redis 3.2.9 as result backend.
Although I can get rabbit queue depth by management API(e.g. get_queue_depth from pyrabbit package), this results the whole queue depth, not pending number before specified task id.
And I know I could maintain a queue managing pushed task ids by myself.
But I wanna if there is any easy way by celery or rabbitmq itself.
Thanks.
I'm not sure if it answer your question but there is control client that can help you to inspect reserved
tasks, active
tasks and so on..
i = app.control.inspect()
i.reserved()
#output:
[{'worker1.example.com':
[{'name': 'tasks.sleeptask',
'id': '32666e9b-809c-41fa-8e93-5ae0c80afbbf',
'args': '(8,)',
'kwargs': '{}'}]}]
for more info: http://docs.celeryproject.org/en/latest/userguide/workers.html#dump-of-reserved-tasks
You can also monitor/inspect from command line: http://docs.celeryproject.org/en/latest/userguide/monitoring.html#commands
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