This is a simple "hello world" case for python based task queue celery on ubuntu 9.10.
Install
sudo apt-get install rabbitmq-server
sudo easy_install celery
In celerytest directory:
Create celeryconfig.py:
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"
CELERY_RESULT_BACKEND = "amqp"
import os
import sys
sys.path.append(os.getcwd())
CELERY_IMPORTS = ("tasks", )
Create tasks.py:
from celery.decorators import task
@task
def add(x, y):
return x + y
Start celery worker:
celeryd
Excute the program:
python -c "from tasks import *;r=add.delay(3,5);print r.wait()"
Install
sudo apt-get install rabbitmq-server
sudo easy_install celery
In celerytest directory:
Create celeryconfig.py:
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"
CELERY_RESULT_BACKEND = "amqp"
import os
import sys
sys.path.append(os.getcwd())
CELERY_IMPORTS = ("tasks", )
Create tasks.py:
from celery.decorators import task
@task
def add(x, y):
return x + y
Start celery worker:
celeryd
Excute the program:
python -c "from tasks import *;r=add.delay(3,5);print r.wait()"
Comments