Question

I am trying to run celery with IronMQ and cache in a Django project on Heroku but I am receiving the following:

2013-04-14T22:29:17.479887+00:00 app[celeryd.1]: ImportError: No module named tasks

What am I doing wrong? The following is my relevant code and djcelery and my app are both in installed apps:

REQUIREMENTS (Rabbit AMQP is in there because I tried that before IronMQ):

Django==1.5.1
amqp==1.0.11
anyjson==0.3.3
billiard==2.7.3.27
boto==2.8.0
celery==3.0.18
dj-database-url==0.2.1
django-celery==3.0.17
django-storages==1.1.8
gunicorn==0.17.2
iron-cache==0.2.0
iron-celery==0.3.1
iron-core==1.0.2
iron-mq==0.4
iso8601==0.1.4
kombu==2.5.10
psycopg2==2.4.6
python-dateutil==2.1
pytz==2013b
requests==1.2.0
six==1.3.0
wsgiref==0.1.2

PROCFILE:

web: gunicorn myapp.wsgi
celeryd: celery -A tasks worker --loglevel=info -E

SETTINGS:

BROKER_URL = 'ironmq://'
CELERY_RESULT_BACKEND = 'ironcache://'

import djcelery
import iron_celery

djcelery.setup_loader()

TASKS:

from celery import task
@task()
def batchAdd(result_length, result_amount):

VIEWS:

from app import tasks
r = batchAdd.delay(result_length, result_amount)
return HttpResponse(r.task_id)

ALSO TRIED (in VIEWS):

from tasks import batchAdd
r = batchAdd.delay(result_length, result_amount)
return HttpResponse(r.task_id)

AND TRIED THIS AS WELL (in VIEWS):

from app.tasks import batchAdd
r = batchAdd.delay(result_length, result_amount)
return HttpResponse(r.task_id)

Also here is my structure:

projectname
--app
----__init__.py
----__init__.pyc
----admin.py
----admin.pyc
----forms.py
----forms.pyc
----models.py
----models.pyc
----tasks.py
----tests.py
----views.py
----views.pyc
--manage.py
--Procfile
--projectname
----__init__.py
----__init__.pyc
----settings.py
----settings.pyc
----static
----templates
----urls.py
----urls.pyc
----wsgi.py
----wsgi.pyc
--requirements.txt
Était-ce utile?

La solution

Have you tried to load celery via manage.py ?

python manage.py celery worker --loglevel=info

Autres conseils

You can't just run your celery using:

celery -A tasks worker --loglevel=info -E

Celery requires celeryconfig file with -A option. You should run you celery as described in djcelery docs.

python manage.py celery worker --loglevel=info

Also you should fix your views.py as

from app.tasks import batchAdd
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top