推荐学习书目
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
darksand
V2EX  ›  Python

celery 经常卡死,求帮助

  •  
  •   darksand · Aug 6, 2018 · 6762 views
    This topic created in 2863 days ago, the information mentioned may be changed or developed.

    celery worker 经常卡死,例如 并发数 是 4,然后经常就有 4 个任务状态卡在 started 或者 received 不动,然后也不会抛出异常。我是设置了超时的 CELERYD_TASK_SOFT_TIME_LIMIT = 120

    但是时间过了很久 也不会抛出 异常 SoftTimeLimitExceeded

    我看文档是肯定会抛出的。但是这个有的时候能抛出,有的时候不会抛出,然后就卡死在那个地方! 整了一周了还是没找到问题

    11 replies    2018-10-16 08:54:55 +08:00
    ohhe
        1
    ohhe  
       Aug 6, 2018
    什么版本
    某些版本有这样的问题
    WinMain
        2
    WinMain  
       Aug 7, 2018
    用的 redis ?
    myyou
        3
    myyou  
       Aug 7, 2018
    celery 的确会这样,内存占用会越来越多,然后就假死,建议写个检测脚本定时重启。
    或者找一个替代品例如这个: https://github.com/Bogdanp/dramatiq
    darksand
        4
    darksand  
    OP
       Aug 7, 2018
    @WinMain rabbitmq
    darksand
        5
    darksand  
    OP
       Aug 7, 2018
    @myyou 如果用检测脚本定时重启的话,请问怎么检测到是否假死呢?
    myyou
        6
    myyou  
       Aug 7, 2018
    @darksand 之前做的是每隔一段时间就检测 celery 所有进程内存占用,到一定量时不管假不假死都重启。你可以根据是否有日志输出来重启。
    实际我还是建议你换这个 https://github.com/Bogdanp/dramatiq,celery 我一直怀疑它内存泄漏。
    darksand
        7
    darksand  
    OP
       Aug 7, 2018
    @myyou 感谢
    darksand
        8
    darksand  
    OP
       Aug 7, 2018
    @ohhe 用的 4.2.0
    ohhe
        9
    ohhe  
       Aug 7, 2018
    try 4.1 或者 3.1
    qq7171891
        10
    qq7171891  
       Oct 16, 2018
    我也是。。我头都大了。。任何异常不抛出,同时使用 beat 和 worker,会发现 beat 很好,worker 会过几天突然莫名其妙的不执行了,Received task 都没有了,但是开了 Debug 模式,没有任何异常报告。
    qq7171891
        11
    qq7171891  
       Oct 16, 2018
    实在不成打算用 RQ 了。不好的地方就是首先要重新学习,其次 RQ 没有原生支持类似 beat 这样的计划任务模块,但有扩展包,别人写了一个。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3121 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 13:01 · PVG 21:01 · LAX 06:01 · JFK 09:01
    ♥ Do have faith in what you're doing.