Has anyone succeeded in using celery with pylons

I have pylons based webapp and I would like to use celery + rabbitmq for some time while accepting tasks. I looked at the celery-pylons project, but I was not able to use it.

My main problem with celery: where can I put the celeryconfig.py file or is there any other way to specify celery options, for example. BROKER_HOST, etc. From the pylons application (you can also use the django settings.py parameters when using django-celery).

In principle, I investigated 2 options: the use of celery as an autonomous project and the use of celery pylons, without much success ..: (

Thanks in advance for your help.

+4
source share
2 answers

I am doing this at present, although I have not updated celery for some time. I'm still on 2.0.0.

I did to create the celery_app directory in my pylons application. (therefore, in the same directory as data, controllers, etc.)

This directory contains 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, etc. to the celery tasks.py file. In this way, the pylons are initialized and then imports tasks.py.

Then, in celeryconfig, myapp.celery_app.pylons_tasks is set to CELERY_IMPORTS.

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

Hope this helps.

+3
source

The most rigorous integration with pylons is to create a custom bootloader in insert commands. This is what celery pylons do. Check out your celery pylons fork https://bitbucket.org/dougtabuchi/celery-pylons/src , which should work with the latest celery and pylons 1.0.

To get celeryd working, you need to add the correct parameters to your ini file and then call paster celeryd development.ini

For the webapp side, you just need to import celerypylons into environment.py. Then you can import and use your tasks from anywhere in your project.

A good pylon project to see what celery uses is https://rhodecode.org/rhodecode/files/tip/

+1
source

All Articles