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.
Install celery-pylons (see :ref:`installation`)
- 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 :$ paster celeryd development.ini
|||Application label may vary depending on Pylons setup.|
|||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.