Installing celery-pylons is dead simple. Follow the two steps below to get Celery integrated with Pylons.
There are a few simple steps to integrate Celery into your Pylons project.
Install celery-pylons (see Installation)
Add the following [2] to your development.ini file in the section [app:main] [1]:
broker.host = localhost broker.port = 5672 broker.user = [user] [password] broker.password = [password] broker.vhost = [vhost] celery.result.backend = amqp celery.result.dburi = amqp:// celery.imports = [list of classes: app.tasks.module]That’s it! Give it a try [3]:
$ paster celeryd development.ini
Please Note:
[1] | Application label may vary depending on Pylons setup. |
[2] | Working on the assumption you’ve set up user, vhost, etc using rabbitmqctl |
[3] | Depending on your Pylons setup, you may need to append #_your_app_name_ to the development.ini paster config file argument: $ paster celeryd development.ini#foo
|
Assuming you’ve got your virtualenv activated:
$ paster celeryd -B
However, in production you’ll probably want to run the work in the background as a daemon. You’ll need to rely on the tools provided by your platform. See the celery docs Running Celery as a Daemon.
For a complete listing of the command line optinos available, use the help command:
$ paster help
Please note: All the tasks have to be stored in a real module, they can’t be defined in the python shell or ipython/bpython. This is because the celery worker server needs access to the task function to be able to run it.
Put tasks in the tasks module of your Pylons application. The worker server will not automatically load your tasks. They must be listed in your development.ini file.
see Configuring your Pylons project to use Celery for more information.
To learn more you should read the Celery User Guide, and the Celery Documentation.
Want to learn more about RabbitMQ? Check out their getting started page for a plethora of information.
Or, take a look at RabbitMQ’s configuration page for more details on RabbitMQ configuration