Celery checks the number of tasks before the specified task

Does celery support returning pending number jobs to a given task identifier?

For example, without working with celery, I press task1, task2, task3, all three are waiting, now what I want, if I give task3, it tells me that before 3 there are two waiting tasks.

I use celery celery 4.1, rabbit 3.5.4 as a broker and redis 3.2.9 as a result.

Although I can get the depth of the rabbit queue using the management API (for example, get_queue_depth from the pyrabbit package), this will result in the full depth of the queue, and not the waiting number to the specified task identifier.

And I know that I could support the queue by managing the pressed task identifiers myself.

But I want if there is any simple way using celery or the rabbit itself.

Thank.

+4
source share
1 answer

I'm not sure if he will answer your question, but there is a client control that will help you check tasks reserved, activetasks, etc.

i = app.control.inspect()
i.reserved()

#output:
[{'worker1.example.com':
    [{'name': 'tasks.sleeptask',
      'id': '32666e9b-809c-41fa-8e93-5ae0c80afbbf',
      'args': '(8,)',
      'kwargs': '{}'}]}]

for more information: http://docs.celeryproject.org/en/latest/userguide/workers.html#dump-of-reserved-tasks

You can also control / check from the command line: http://docs.celeryproject.org/en/latest/userguide/monitoring.html#commands

+1
source

Source: https://habr.com/ru/post/1685946/


All Articles