Installation

_$: cd code
_$: virtualenv celery
_$: cd celery ; mkdir celery
_$: source bin/activate
(celery)_$: pip install celery

A simple file

/code/celery/bin
             celery/
                    tasks.py
             include
             lib
             local
/code/celery/celery/tasks.py:
-----------------------------
from celery import Celery

celery = Celery('tasks', backend='amqp', broker='amqp://guest@localhost//')

@celery.task
def add(x, y):
    return x + y

@celery.task
def sub(x,y):
    return x - y

Now open 2 shells.

# shell 1
(celery)_$: celery worker -A tasks --loglevel=info
# shell 2
_$: cd code/celery/celery
_$: python
Python 2.7.3 (default, Sep 26 2013, 16:35:25) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tasks import *
>>>
>>> add.delay(1,2)
<AsyncResult: 23257efc-ecca-4729-b615-c3a0f93beb58>
>>>
>>> quit()

A simple file + Supervisor

/code/celery/celery/celery.supervisor:
--------------------------------------
###
# supervisor configuration
###

[program:celeryd]
command=/home/dceresuela/code/celery/bin/celery worker --app=tasks --loglevel=info
environment=PYTHONPATH=/home/dceresuela/code/celery/celery
directory=/home/dceresuela/code/celery/celery
stdout_logfile=/var/log/supervisor/%(program_name)s-supervisor.log
stderr_logfile=/var/log/supervisor/%(program_name)s-supervisor.log
stopsignal=INT

A project + Supervisor

/code/celery/bin
             celery/
                    celery.supervisor
                    proj/
                         celery.py
                         __init__.py
                         tasks.py
             include
             lib
             local
/etc/supervisor/supervisord.conf:
---------------------------------
...
[include]
files = /etc/supervisor/conf.d/*.conf /home/<user>/code/celery/celery/*.supervisor
/code/celery/celery/celery.supervisor:
--------------------------------------
###
# supervisor configuration
###

[program:celeryd]
command=/home/dceresuela/code/celery/bin/celery worker --app=proj --loglevel=info
environment=PYTHONPATH=/home/dceresuela/code/celery/celery
directory=/home/dceresuela/code/celery/celery
stdout_logfile=/var/log/supervisor/%(program_name)s-supervisor.log
stderr_logfile=/var/log/supervisor/%(program_name)s-supervisor.log
stopsignal=INT
/code/celery/celery/proj/celery.py:
-----------------------------------
from __future__ import absolute_import
from celery import Celery

#celery = Celery('tasks', backend='amqp', broker='amqp://guest@localhost//')
celery = Celery('proj.celery',
                broker='amqp://guest@localhost//',
                backend='amqp',
                include=['proj.tasks'])

if __name__ == '__main__':
    celery.start()
/code/celery/celery/proj/__init__.py:
-------------------------------------
# Empty, just to make it a python module
/code/celery/celery/proj/tasks.py:
----------------------------------
from __future__ import absolute_import
from proj.celery import celery

@celery.task
def add(x, y):
    return x + y

@celery.task
def sub(x,y):
    return x - y
# shell 1
_$: supervisorctl start celeryd
# shell 2
_$: cd /code/celery/celery
_$: python
Python 2.7.3 (default, Apr 10 2013, 05:13:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from proj.tasks import *
>>> add.delay(6,6)
<AsyncResult: ab2ed05f-fd00-4c17-98d3-05b8b1b61a0a>
>>> quit()

Check configuration

_$: celery inspect conf

Delete all tasks

_$: celery purge
_$: celery purge --app=celery_photo

Delete a queue

_$: celery amqp queue.purge 9a3544d762e8440c9c96a3876584b234