celery-pylons / docs / getting-started / first-steps-with-pylons.rst

Full commit

First steps with celery-pylons

Configuring your Pylons project to use Celery

There are a few simple steps to integrate Celery into your Pylons project.

  1. Install celery-pylons (see :ref:`installation`)

  2. Add the following [2] to your development.ini file in the section [app:main] [1]: = 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]
  3. 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

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

Running the celery worker server

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

Defining and executing tasks

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.

Where to go from here

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