简体   繁体   中英

How to delete tasks from celery task queue?

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM