everyone. I have problem using Django==1.5
with django-celery==3.0.11
I get error: [Errno 61] Connection refused
when I run following code from django shell
from data_warehouse.tasks import add
add.delay(4,4)
settings.py
INSTALLED_APPS += ('djcelery')
# Settings for Celery Task Scheduler
BROKER_URL = 'mongodb://'
import djcelery
djcelery.setup_loader()
data_warehouse.tasks (copied from tutorial)
from celery.task import task
@task()
def add(x, y):
return x + y
when I run python manage.py celery worker -l info I get
-------------- celery@Atthaphongs-MacBook-Air.local v3.0.16 (Chiastic Slide)
---- **** -----
--- * *** * -- [Configuration]
-- * - **** --- . broker: mongodb://localhost//
- ** ---------- . app: default:0x10f215810 (djcelery.loaders.DjangoLoader)
- ** ---------- . concurrency: 4 (processes)
- ** ---------- . events: OFF (enable -E to monitor this worker)
- ** ----------
- *** --- * --- [Queues]
-- ******* ---- . celery: exchange:celery(direct) binding:celery
--- ***** -----
[Tasks]
. data_warehouse.tasks.add
/Users/atthaphong/VirtualEnvs/report/lib/python2.7/site-packages/djcelery/loaders.py:132: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn("Using settings.DEBUG leads to a memory leak, never "
[2013-03-23 01:38:22,999: WARNING/MainProcess] /Users/atthaphong/VirtualEnvs/report/lib/python2.7/site-packages/djcelery/loaders.py:132: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn("Using settings.DEBUG leads to a memory leak, never "
[2013-03-23 01:38:23,000: WARNING/MainProcess] celery@Atthaphongs-MacBook-Air.local ready.
[2013-03-23 01:38:23,002: INFO/MainProcess] consumer: Connected to mongodb://localhost//.
/Users/atthaphong/VirtualEnvs/report/lib/python2.7/site-packages/pymongo/mongo_client.py:274: UserWarning: database name in URI is being ignored. If you wish to authenticate to admin, you must provide a username and password.
"and password." % (db,))
[2013-03-23 01:38:23,005: WARNING/MainProcess] /Users/atthaphong/VirtualEnvs/report/lib/python2.7/site-packages/pymongo/mongo_client.py:274: UserWarning: database name in URI is being ignored. If you wish to authenticate to admin, you must provide a username and password.
"and password." % (db,))
when I tried run a task using python shell with this code
from celery import Celery
celery = Celery('tasks', broker='mongodb://')
celery.conf.CELERY_RESULT_BACKEND = "mongodb"
@celery.task
def add(x, y):
return x + y
I get this expected error.
[2013-03-23 02:04:30,218: ERROR/MainProcess] Received unregistered task of type 'tasks.add'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you are using relative imports?
the problem might come from Celery instance doesn't call the right broker url but I haven't figured it out yet. Do you have any idea about this?
Solved!! Just add
BROKER_TRANSPORT = 'mongodb'
To settings.py