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

celery 到底能不能动态添加周期任务

  •  
  •   hanssx · Aug 23, 2019 · 3969 views
    This topic created in 2602 days ago, the information mentioned may be changed or developed.
    动态即通过前端 UI 等手段自定义周期时间,而不是通过初始化时写配置文件,经过 gg 和实践摸索,发现并不能实现动态添加周期任务。
    https://stackoverflow.com/questions/10194975/how-to-dynamically-add-remove-periodic-tasks-to-celery-celerybeat/43752416
    倒数第 3 个回答,提到了文档中的使用 https://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#entries
    然后我使用文档中的例子 add_periodic_task,并没有成功,文档中说的不是动态添加?
    13 replies  •  2019-08-27 14:17:43 +08:00
    GoLand
        1
    GoLand  
       Aug 23, 2019   ❤️ 1
    添加了 periodic task 得重启 beat 和 celery 的,动态添加不了。
    HFcbyqP0iVO5KM05
        2
    HFcbyqP0iVO5KM05  
       Aug 24, 2019 via Android   ❤️ 1
    可以添加,但是默认没有,得自己实现。
    beat 也是周期性从文件读任务参数。
    ynkkdev
        3
    ynkkdev  
       Aug 24, 2019   ❤️ 1
    django celery beat 是可以实现读取数据库中动态生成的任务周期设置,来实现你说的这个需求的
    ynkkdev
        4
    ynkkdev  
       Aug 24, 2019
    当然你要是没有用 django 的话,其他的框架有没有提供类似的第三方包我就不清楚了
    hanssx
        5
    hanssx  
    OP
       Aug 24, 2019
    @GoLand
    @gulu
    @youngce 谢谢三位,我明白了。
    linvaux
        6
    linvaux  
       Aug 24, 2019
    最近也在学习 celery,感觉有点复杂
    Eds1995
        7
    Eds1995  
       Aug 25, 2019 via Android
    GitHub 上有一个用 redis 来实现动态添加任务的库,rebeat
    hanssx
        8
    hanssx  
    OP
       Aug 26, 2019
    @Eds1995 兄弟我没搜到你这个库啊
    hanssx
        9
    hanssx  
    OP
       Aug 26, 2019
    Eds1995
        10
    Eds1995  
       Aug 26, 2019   ❤️ 1
    hanssx
        11
    hanssx  
    OP
       Aug 26, 2019
    @Eds1995 感谢,不过不怎么会用,文档有点少。
    hanssx
        12
    hanssx  
    OP
       Aug 26, 2019
    推荐个国人写的,但是我用着有些问题,examples/base/tasks.py 文件是没有问题的,https://github.com/AngelLiang/celery-sqlalchemy-scheduler
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5959 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 109ms · UTC 06:28 · PVG 14:28 · LAX 23:28 · JFK 02:28
    ♥ Do have faith in what you're doing.