Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-celery: No result backend configured

I am trying to use django-celery in my project

In settings.py I have

CELERY_RESULT_BACKEND = "amqp"

The server started fine with

python manage.py celeryd --setting=settings

But if I want to access a result from a delayed task, I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\celery\result.py", line 108, in ready
    return self.status in self.backend.READY_STATES
  File "C:\Python27\lib\site-packages\celery\result.py", line 196, in status
    return self.state
  File "C:\Python27\lib\site-packages\celery\result.py", line 191, in state
    return self.backend.get_status(self.task_id)
  File "C:\Python27\lib\site-packages\celery\backends\base.py", line 404, in _is
_disabled
    raise NotImplementedError("No result backend configured.  "
NotImplementedError: No result backend configured.  Please see the documentation
 for more information.

It is very strange because when I just run celeryd (with the same celery settings), it works just fine. Has anyone encountered this problem before?

Thanks in advance!

like image 818
airfang Avatar asked Dec 08 '11 06:12

airfang


3 Answers

I had the same problem while getting the result back from the celery task although the celery task was executed ( console logs). What i found was, i had the same setting CELERY_RESULT_BACKEND = "redis" in django settings.py but i had also instantiated celery in the tasks.py

celery = Celery('tasks', broker='redis://localhost') - which i suppose overrides the settings.py property and hence it was not configuring the backend server for my celery instance which is used to store the results.

i removed this and let django get celery get properties from settings.py and the sample code worked for me.

like image 134
psekar Avatar answered Oct 16 '22 12:10

psekar


If you're just running the samples from http://www.celeryproject.org/tutorials/first-steps-with-celery/, you need to run the console via manage.py:

% python manage.py shell

like image 37
per06a Avatar answered Oct 16 '22 11:10

per06a


For those who are in a desperate search for a solution like I was.

Put this line at the end of the settings.py script:

djcelery.setup_loader()

Looks like django-celery is not going to consider it's own settings without a strict order.

like image 26
Oleg Kirichenko Avatar answered Oct 16 '22 12:10

Oleg Kirichenko