我有一个以 Redis 作为代理的 celery 应用。
代码由以下循环组成:
running = []
res = add.apply_async([1,2], queue='add')
running.append(res)
while running:
r = running.pop()
if r.ready():
print r.get()
else:
running.insert(0,r)
一切正常,但是当我 redis-cli
进入 redis 并执行 keys *
我看到一堆 celery-task-meta 键。
他们为什么不清理?
那些是干什么用的?
--
[编辑]
我读过 CELERY_TASK_RESULT_EXPIRES 设置。
Redis中的task key是否可以在读取结果后立即清理,而不是等到过期时间?
最佳答案
来自 Celery 文档:
AsyncResult.forget()
Forget about (and possibly remove the result of) this task.
你必须先 r.get()
然后 r.forget()
但是,您不需要清理 key 。 对于,doc说:
CELERY_TASK_RESULT_EXPIRES
默认为 1 天后过期。
关于python - Celery:Redis 作为代理离开任务元键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34127864/