简体   繁体   English

芹菜金字塔定期任务

[英]Pyramid periodic task with Celery

I'm try to use pyramid_celery. 我尝试使用pyramid_celery。 I managed to run simple tasks. 我设法运行一些简单的任务。 But how with pyramid run of a periodic tasks? 但是如何用金字塔运行定期任务呢? Where I need to write CELERYBEAT_SCHEDULE? 我需要在哪里写CELERYBEAT_SCHEDULE?

Using Pyramid with Celery does not require using pyramid_celery module - the latter is just a thin integration layer which may or may not make your life easier. 将Pyramid与Celery结合使用并不需要使用pyramid_celery模块-后者只是一个薄的集成层,可能会或可能不会使您的生活变得更轻松。 In your case it looks like it doesn't make your life easier, right? 就您而言,这似乎并没有使您的生活更轻松,对吗?

Both Pyramid and Celery have excellent and very detailed documentation. 金字塔和芹菜都有出色且非常详细的文档。 pyramid_celery does not have detailed documentation. pyramid_celery没有详细的文档。 From my reading the code it looks like it reads celery configuration from paster .ini file (development.ini in case of pyramid_celery_demo app) - I have no idea how to stick a nested dict into an .ini file, but some commit messages suggest that it somehow should work . 从我阅读的代码来看,它看起来像是从Paster .ini文件(对于pyramid_celery_demo应用程序而言为development.ini)读取celery配置-我不知道如何将嵌套的字典粘贴到.ini文件中,但是一些提交消息表明它应该以某种方式工作

In short, your options are: 简而言之,您可以选择:

  • read the code of pyramid_celery and figure out how it supposed to work 阅读pyramid_celery的代码并弄清楚它应该如何工作

  • write to the author of the package 给包裹的作者写信

  • drop the package and use plain Pyramid and plain Celery, enjoying nice and clear documentation. 放下包装,使用普通的金字塔和普通的芹菜,享受清晰的文档。

Further reading the code suggests that they 'eval()' string values read from the .ini file to convert them to python structures, so I'd assume putting something like 进一步阅读代码表明,它们从.ini文件中读取的'eval()'字符串值将其转换为python结构,因此我假设放置类似

CELERYBEAT_SCHEDULE = "{'key': 'value', 'another_key': 'another_value'}"

should do the trick... 应该做到这一点...

you need to add below section to your developement.ini file of project 您需要将以下部分添加到项目的developmentement.ini文件中

[celerybeat:task1]
task = app1.tasks.Task1
type = crontab
schedule = {"minute": 0}

schedule is the format you need to write in cron style.Task1 is the task to be executed . schedule是您需要以cron样式编写的格式。Task1是要执行的任务。 Hope you got it. 希望你明白了。 For more details visit this link. 有关更多详细信息,请访问此链接。 https://pypi.python.org/pypi/pyramid_celery/ https://pypi.python.org/pypi/pyramid_celery/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM