1

How can i delete all tasks in a queue, right after a task ended?

I want something like this (Deleting all pending tasks in celery / rabbitmq) but for celery 3.0.

Thanks

EDIT:

From celery documentation: http://docs.celeryproject.org/en/latest/faq.html#how-do-i-purge-all-waiting-tasks

My code looks like:

from celery import current_app as celery

@task
def task_a():
    celery.control.purge()

I was expecting that, if i issued 5 tasks, only the first would run. Somehow, i'ts not doind that.

Thanks

Community
  • 1
  • 1
luistm
  • 1,027
  • 4
  • 18
  • 43

1 Answers1

1

Those tasks might have been already prefetched by workers. To find out is this so, try to run amount of tasks more than active workers multplied by prefetch multiplier (see below), and check what result is returned by celery.control.purge(). You can control amount of prefetched tasks using config parameters CELERYD_PREFETCH_MULTIPLIER and CELERY_ACKS_LATE.

alko
  • 46,136
  • 12
  • 94
  • 102