1

We are using celery with redis.

We had some wrong celery architecture implemented in our project. So tasks were being added to celery faster than they were being processed. So the queue became larger and larger.

We have changed the design of our project, and it will not happen hereafter.

But celery has a large backlog which I want to remove. To be precise we have 800000 backlogged tasks in a queue.

We have a single queue but two different types of tasks have been added to this queue. We have a task named func_a and another name func_b. The queue contains 300000 of func_a and 500000 of func_b.

I want to remove all occurences func_a from the queue. What is the simplest way to accomplish this?

zero323
  • 322,348
  • 103
  • 959
  • 935
Akshar Raaj
  • 14,231
  • 7
  • 51
  • 45
  • possible duplicate of [How to inspect and cancel Celery tasks by task name](http://stackoverflow.com/questions/15575826/how-to-inspect-and-cancel-celery-tasks-by-task-name) – scytale Jul 03 '15 at 16:40

1 Answers1

1

something like this should do it:

from path.to.your.tasks import app

i = app.control.inspect()

for worker, jobs in i.scheduled().iteritems():
    for job in jobs:
        if job['task_name'] == 'path.to.your.tasks.func_a'
            app.AsyncResult(job['id']).revoke()
scytale
  • 12,346
  • 3
  • 32
  • 46