0
votes

I need in my django project run long tasks. Desided to use celery with redis as broker. Installed redis runs:

The server is now ready to accept connections on port 6379

Than I install django-celery, configure:

import djcelery
djcelery.setup_loader()
BROKER_HOST = "localhost"
BROKER_PORT = 6379 #redis
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"

and run it:

python manage.py celeryd -l DEBUG
[...]
[2011-06-18 10:31:37,913: DEBUG/MainProcess] Starting thread Timer...
[2011-06-18 10:31:37,914: DEBUG/MainProcess] Starting thread Consumer... 
[2011-06-18 10:31:37,914: WARNING/MainProcess] celery@greg... has started.
[2011-06-18 10:31:37,914: DEBUG/MainProcess] Consumer: Re-establishing connection to the broker...

my example task look like:

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

now I try to run it in shell:

In [3]: from message.tasks import add
In [4]: r=add.delay(2, 5)    

it wait very long and render Traceback http://dpaste.com/555939/. What it can be? Maybe I miss something?

2

2 Answers

2
votes

The BROKER_BACKEND setting is missing. Here is a example config for using Redis:

import djcelery
djcelery.setup_loader()

CELERY_RESULT_BACKEND = 'database'

BROKER_BACKEND = 'redis'
BROKER_HOST = 'localhost'
BROKER_PORT = 6379
BROKER_VHOST = '1'
0
votes

Don't know what this is, but I do know that RabbitMQ is the recommended broker for Celery and Django. I have it running and it works like a charm. Why not give that one a go?