V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Aug 24, 2016 · 5734 views
    This topic created in 3534 days ago, the information mentioned may be changed or developed.

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

    9 replies    2016-08-25 12:58:11 +08:00
    starsoi
        1
    starsoi  
       Aug 24, 2016   ❤️ 1
    用 AsyncResult 对象的 forget()方法

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

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

    多谢各位!
    woostundy
        6
    woostundy  
    OP
       Aug 25, 2016
    如果不设置 CELERY_TASK_RESULT_EXPIRES ,默认超时应该是 24 小时,奇怪的是 24 小时后 result 的 TTL 变成了-1 ,却没有被清除。
    Phant0m
        7
    Phant0m  
       Aug 25, 2016
    @woostundy 你的 result backend 用的 redis?
    julyclyde
        8
    julyclyde  
       Aug 25, 2016
    @woostundy 你在它过期之前观察一下 TTL 是不是逐步下降的。如果逐步下降,那就没 celery 什么事了,是 redis 的职责
    fanzheng
        9
    fanzheng  
       Aug 25, 2016
    我现在是把 result 的 broker 删除了的,不保存 result ,或者用 sqlite 算了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1238 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 17:38 · PVG 01:38 · LAX 10:38 · JFK 13:38
    ♥ Do have faith in what you're doing.