celery task clean-up with DB backend

懵懂的女人 提交于 2019-12-21 03:57:07

问题


I'm trying to understand how and when tasks are cleaned up in celery. From looking at the task docs I see that:

Old results will be cleaned automatically, based on the CELERY_TASK_RESULT_EXPIRES setting. By default this is set to expire after 1 day: if you have a very busy cluster you should lower this value.

But this quote is from the RabbitMQ Result Backend section and I do not see any similar text in the Database Backend section. So my question is: is there a backend agnostic approach I can take for old task clean-up with celery and if not is there a DB Backend specific approach I should take? Incase it makes any difference I'm using django-celery. Thanks.


回答1:


If you click on the link to the setting doc for CELERY_TASK_RESULT_EXPIRES:

http://docs.celeryproject.org/en/latest/userguide/configuration.html#result-expires

It does say that database supports this, but then you need to run celery beat (there's a default periodic task, called every day, to remove expired results).

The backend docs in the task should probably mention this as well, maybe there should be a dedicated guide for backends too. If you want to lobby for this, then please open up an issue at https://github.com/celery/celery/issues



来源:https://stackoverflow.com/questions/13147581/celery-task-clean-up-with-db-backend

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