celery job 执行完后,在 redis 里堆积了大量残余信息,应该去哪设置清理?

2016 年 8 月 24 日
 woostundy

每次执行完后 TTL 变成了-1 ,但数据会一直残留着。该怎么解决?

5734 次点击
所在节点    Python
9 条回复
starsoi
2016 年 8 月 24 日
用 AsyncResult 对象的 forget()方法

result = some_task.delay()
result.forget()
julyclyde
2016 年 8 月 24 日
残留的是 result 还是什么?
Phant0m
2016 年 8 月 24 日
设置执行结果过期时间 “ CELERY_TASK_RESULT_EXPIRES ”
woostundy
2016 年 8 月 25 日
@julyclyde 残留的是 result ,但 result.forget()并不起作用。而且我将 CELERY_TASK_RESULT_EXPIRES 设置成了 30 ,依然没有效果。
woostundy
2016 年 8 月 25 日
@julyclyde
@starsoi
@Phant0m

汗 (⊙﹏⊙)b 是我配置文件写错了, CELERY_TASK_RESULT_EXPIRES 可以生效。
但 @starsoi result.forget()不知为何并没有生效。

多谢各位!
woostundy
2016 年 8 月 25 日
如果不设置 CELERY_TASK_RESULT_EXPIRES ,默认超时应该是 24 小时,奇怪的是 24 小时后 result 的 TTL 变成了-1 ,却没有被清除。
Phant0m
2016 年 8 月 25 日
@woostundy 你的 result backend 用的 redis?
julyclyde
2016 年 8 月 25 日
@woostundy 你在它过期之前观察一下 TTL 是不是逐步下降的。如果逐步下降,那就没 celery 什么事了,是 redis 的职责
fanzheng
2016 年 8 月 25 日
我现在是把 result 的 broker 删除了的,不保存 result ,或者用 sqlite 算了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/301563

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX