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

celery 如何通过 task_id 查询任务的执行日志

  •  
  •   Alexf4 ·
    alexcc4 · Apr 2, 2021 · 2875 views
    This topic created in 2004 days ago, the information mentioned may be changed or developed.

    最近在使用 celery 做任务队列,用 flower 已经可以满足查看某个任务的执行状态,参数,时间等等。

    后面想着定制需求:通过一个 task_id 实时查看执行的情况(类似任务执行里面的 print, logger 等),各位大佬们有没有建议?

    目前自己的大概的想法:

    • 在每个 worker 的执行日志里面操作,做近实时的收集( collectd, fluentd, filebeat 等),然后根据 task_id 在日志的仓库( clickhouse, es )做查询。这个日志搜索会有一定的延迟性
    • 每个 task 配置一个单独的日志文件, 然后在进行查询时候, 利用 websocket 连接服务器(此时服务器找到对应的文件, tail -f )。
    2 replies  •  2021-04-02 15:52:01 +08:00
    strict
        1
    strict  
       Apr 2, 2021
    简单粗暴,把日志关键数据塞到 result backend 中.
    Alexf4
        2
    Alexf4  
    OP
       Apr 2, 2021
    @strict 这个只是保存任务的一些必要参数吧。执行结果,参数,执行时间等等。
    但是像执行日志,类似任务 stdout 输出, 不会在这里面吧?还是有啥盲点我没发现的吗,华生
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2767 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 12:33 · PVG 20:33 · LAX 05:33 · JFK 08:33
    ♥ Do have faith in what you're doing.