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

celery worker 跑跑就不工作了. 如何 debug?

  •  
  •   chaleaoch · Dec 17, 2020 · 3419 views
    This topic created in 2118 days ago, the information mentioned may be changed or developed.
    大佬给指条明路.

    rabbitmq 好好的. 因为 beat 不停的发消息. 成功的.
    现在是消费者挂了,但是进程还在啊.
    9 replies  •  2020-12-25 16:38:36 +08:00
    northisland
        1
    northisland  
       Dec 17, 2020
    不搞架构,但用过 celery,纯属业余

    我记得把 celery.tasks 里的函数,可以直接放在 test.py 的主函数里,按照 log 过一遍可疑的 mq 输入,应该能搞定复现。
    northisland
        2
    northisland  
       Dec 17, 2020
    @celery.task
    的函数可以直接运行,不用连队列。
    4everLoveU
        3
    4everLoveU  
       Dec 17, 2020
    1 、celery 启动有 debug 模式,打印的内容还是比较详细的;
    2 、重载一下 celery.Task,自己实现 on_failure 功能,看看 trace

    ```python
    class CustomTask(celery.Task):

    ...

    def on_failure(self, exc, event_id, args, kwargs, einfo):
    # do something
    ```
    cz5424
        4
    cz5424  
       Dec 17, 2020 via iPhone
    看看是不是有耗时很久的队列,一直卡着走不动,比如 requests 没写 timeout
    simple2025
        5
    simple2025  
       Dec 17, 2020
    有什么 log?
    abersheeran
        6
    abersheeran  
       Dec 18, 2020
    Celery 可以让你自己写代码反馈 Task 的进度,用这个 DEBUG,你就知道它卡在哪儿了。
    seven123
        7
    seven123  
       Dec 18, 2020
    之前用过 celery 貌似不太稳定?,可能会出现内存泄露的事情, 所以我会加上这个参数 。
    celery 在长时间运行后可能出现内存泄漏,每个 worker 执行 5 个任务就死掉
    CELERYD_MAX_TASKS_PER_CHILD = 5
    HashV2
        8
    HashV2  
       Dec 18, 2020
    @chaleaoch task 中直接 print 出来任务执行相关情况 celery 启动的时候添加-f 参数指定日志文件 有问题及时查看日志

    @seven123 不错的参数 加上了
    rSP0rcaA9K11Rjsz
        9
    rSP0rcaA9K11Rjsz  
       Dec 25, 2020
    进 flower 看一下每个 worker 的情况,7 楼的情况也有可能
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2312 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 10:00 · PVG 18:00 · LAX 03:00 · JFK 06:00
    ♥ Do have faith in what you're doing.