Celery/Rabbitmq/Django - Old tasks being executed without being called in my code

天涯浪子 提交于 2019-12-25 03:32:42

问题


I have a simple shared celery task like this:

@shared_task
def add():
    x = barakah(name="add()", year="add()", month="add()")
    x.save()
    return "id is add()= " + str(x.id)

And I call it here in this CELERYBEAT_SCHEDULE:

CELERYBEAT_SCHEDULE = {
    'add': {
        'task': 'water.tasks.add',
        'schedule': timedelta(seconds=3),
        'args': ()
    },
}

This is the celery command I use:

celery -A adi worker -B -l info

It runs fine as per schedule but other old tasks are also executing as well. How do I stop the old tasks? I have even tried uninstalling celery and rabbitmq but the old tasks seem to be cached somewhere. I tried this answer but what I tried didn't work. Any ideas?


回答1:


Use celery purge command.

From celery docs:

purge: Purge messages from all configured task queues.

Warning There is no undo for this operation, and messages will be permanently deleted!

$ celery -A proj purge


来源:https://stackoverflow.com/questions/29619510/celery-rabbitmq-django-old-tasks-being-executed-without-being-called-in-my-cod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!