问题
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