有没有人成功地将芹菜与塔一起使用

发布于 2024-09-28 04:17:49 字数 347 浏览 2 评论 0原文

我有一个基于 pylons 的网络应用程序,我喜欢使用 celery +rabbitmq 来完成一些耗时的任务。我查看了 celery-pylons 项目,但没有成功使用它。

我对 celery 的主要问题是:我将 celeryconfig.py 文件放在哪里,或者是否有其他方法来指定 celery 选项,例如。 BROKER_HOST 等,来自 pylons 应用程序(就像使用 django-celery 时可以将选项放入 django settings.py 文件中一样)。

基本上,我研究了 2 个选项:使用 celery 作为独立项目和使用 celery-pylons,两者都没有取得太大成功..:(

提前感谢您的帮助。

I have a pylons based webapp and i'd love to use celery + rabbitmq for some time taking tasks. I've taken a look at the celery-pylons project but I haven't succeeded in using it.

My main problem with celery is: where do i put the celeryconfig.py file or is there any other way to specify the celery options eg. BROKER_HOST and the like, from within a pylons app (In the same way one can put the options in the django settings.py file when using django-celery).

Basically, i investigated 2 options: using celery as a standalone project and using celery-pylons, both without much success.. :(

Thanks in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空心空情空意 2024-10-05 04:17:49

我目前正在这样做,尽管我已经有一段时间没有更新芹菜了。我想我仍然使用 2.0.0。

我所做的是在我的 pylons 应用程序中创建一个 celery_app 目录。 (因此与数据、控制器等位于同一目录中)

在该目录中是我的 celeryconfig.py、tasks.py 和 pylons_tasks.py。

pylons_tasks.py 只是一个初始化 pylons 应用程序的文件,因此我可以将 Pylons 模型等加载到 celerytasks.py 文件中。因此它会执行 pylons init,然后导入tasks.py。

然后将 celeryconfig 设置为使用 myapp.celery_app.pylons_tasks 作为 CELERY_IMPORTS 值。

CELERY_IMPORTS = ("myapp.celery_app.pylons_tasks", )

希望对一些人有所帮助。

I am doing this currently, although I've not updated celery in some time. I'm still on 2.0.0 I think.

What I did was to create a celery_app directory within my pylons application. (so in same directory as data, controllers, etc.)

In that directory are my celeryconfig.py, tasks.py, and pylons_tasks.py.

pylons_tasks.py is just a file that initializes the pylons application so I can load Pylons models and such into the celery tasks.py file. So it does the pylons init and then imports tasks.py.

The celeryconfig is then set to use myapp.celery_app.pylons_tasks as the CELERY_IMPORTS value.

CELERY_IMPORTS = ("myapp.celery_app.pylons_tasks", )

Hope that helps some.

维持三分热 2024-10-05 04:17:49

与 pylons 最紧密的集成是将自定义加载程序构建到粘贴命令中。这就是 celery-pylons 的作用。看看我的 celery-pylons 叉 https://bitbucket.org/dougtabuchi/celery-pylons/src 应该与最新的 celery 和 pylons 1.0 一起使用。

要使 celeryd 端正常工作,您需要在 ini 文件中添加正确的选项,然后调用 Paster celeryddevelopment.ini

对于 webapp 端,您只需要在environment.py 中导入 celerypylons 然后您将能够导入和使用您的任务从项目中的任何地方。

一个很好的使用 celery 的 pylons 项目是 https://rhodecode.org/rhodecode/files/tip /

The tightest integration with pylons is to build a custom loader into paste commands. This is what celery-pylons does. Check out my fork of celery-pylons https://bitbucket.org/dougtabuchi/celery-pylons/src which should work with the latest celery and pylons 1.0.

To get the celeryd side working you need to add the correct options in your ini file and then call paster celeryd development.ini

For the webapp side you just need to import celerypylons in environment.py Then you will be able to import and use your tasks from anywhere in your project.

A good pylons project to look at that uses celery is https://rhodecode.org/rhodecode/files/tip/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文