V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
woostundy
V2EX  ›  Python

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

  •  
  •   woostundy · 2016-08-24 20:16:56 +08:00 · 4885 次点击
    这是一个创建于 2799 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    9 条回复    2016-08-25 12:58:11 +08:00
    starsoi
        1
    starsoi  
       2016-08-24 21:36:03 +08:00   ❤️ 1
    用 AsyncResult 对象的 forget()方法

    result = some_task.delay()
    result.forget()
    julyclyde
        2
    julyclyde  
       2016-08-24 22:54:27 +08:00   ❤️ 1
    残留的是 result 还是什么?
    Phant0m
        3
    Phant0m  
       2016-08-24 23:42:32 +08:00   ❤️ 1
    设置执行结果过期时间 “ CELERY_TASK_RESULT_EXPIRES ”
    woostundy
        4
    woostundy  
    OP
       2016-08-25 10:26:38 +08:00
    @julyclyde 残留的是 result ,但 result.forget()并不起作用。而且我将 CELERY_TASK_RESULT_EXPIRES 设置成了 30 ,依然没有效果。
    woostundy
        5
    woostundy  
    OP
       2016-08-25 10:48:54 +08:00
    @julyclyde
    @starsoi
    @Phant0m

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

    多谢各位!
    woostundy
        6
    woostundy  
    OP
       2016-08-25 10:50:33 +08:00
    如果不设置 CELERY_TASK_RESULT_EXPIRES ,默认超时应该是 24 小时,奇怪的是 24 小时后 result 的 TTL 变成了-1 ,却没有被清除。
    Phant0m
        7
    Phant0m  
       2016-08-25 11:05:57 +08:00
    @woostundy 你的 result backend 用的 redis?
    julyclyde
        8
    julyclyde  
       2016-08-25 11:45:11 +08:00
    @woostundy 你在它过期之前观察一下 TTL 是不是逐步下降的。如果逐步下降,那就没 celery 什么事了,是 redis 的职责
    fanzheng
        9
    fanzheng  
       2016-08-25 12:58:11 +08:00
    我现在是把 result 的 broker 删除了的,不保存 result ,或者用 sqlite 算了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1010 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:12 · PVG 04:12 · LAX 13:12 · JFK 16:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.