【发布时间】:2019-08-29 14:32:41
【问题描述】:
Celery 中是否有任何方法可以通过命令行删除所有以前的任务结果?我能找到的所有内容都参考purge,但这似乎不适用于任务结果。我发现的其他解决方案包括使用 Celery beat 定期删除它,但我正在寻找一次性命令行解决方案。
我使用 Celery 4.3.0。
【问题讨论】:
Celery 中是否有任何方法可以通过命令行删除所有以前的任务结果?我能找到的所有内容都参考purge,但这似乎不适用于任务结果。我发现的其他解决方案包括使用 Celery beat 定期删除它,但我正在寻找一次性命令行解决方案。
我使用 Celery 4.3.0。
【问题讨论】:
所以基于这个答案:How do I delete everything in Redis?
使用 redis-cli:
FLUSHDB - Removes data from your connection's CURRENT database.
FLUSHALL - Removes data from ALL databases.
Redis 文档:
flushdb
flushall
例如,在你的 shell 中:
redis-cli 刷新
并尝试清除芹菜。 来自 celery 文档:http://docs.celeryproject.org/en/latest/faq.html?highlight=purge#how-do-i-purge-all-waiting-tasks
【讨论】:
我认为这就是你要找的东西:
https://github.com/celery/celery/issues/4656
参考
https://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_expires
我是这样设置的:
RESULT_EXPIRE_TIME = 60 * 60 * 4 # keep tasks around for four hours
...
celery = celery.Celery('tasks',
broker=Config.BROKER_URL,
backend=Config.CELERY_RESULTS_BACKEND,
include=['tasks.definitions'],
result_expires=RESULT_EXPIRE_TIME)
【讨论】: