Невозможно поставить задачи в очередь, используя Django 1.5, django-celery 3.0.11 и mongodb
Каждый. У меня проблема с использованием Django==1.5
с django-celery==3.0.11
я получил error: [Errno 61] Connection refused
когда я запускаю следующий код из оболочки Django
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 (скопировано из учебника)
from celery.task import task
@task()
def add(x, y):
return x + y
когда я запускаю python manage.py сельдерея -l информация, которую я получаю
-------------- 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,))
когда я попытался запустить задачу, используя оболочку Python с этим кодом
from celery import Celery
celery = Celery('tasks', broker='mongodb://')
celery.conf.CELERY_RESULT_BACKEND = "mongodb"
@celery.task
def add(x, y):
return x + y
Я получаю эту ожидаемую ошибку.
[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?
проблема может быть связана с тем, что экземпляр Celery не называет URL нужного брокера, но я еще не понял. У вас есть идеи по этому поводу?
Решено!! Просто добавь
BROKER_TRANSPORT = 'mongodb'
В settings.py