Reputation: 1276
My django project is cloned from Celery repo: https://github.com/celery/celery/tree/3.1/examples/django . In settings after const BROKER_URL I added
CELERY_RESULT_BACKEND = 'amqp://'
I'm trying task called 'add' from the project. Inside worker terminal result is ok but can't get it back. I call command something like this:
from demoapp.tasks import add
add.delay(2,2)
add.AsyncResult(a.task_id).get()
But don't know why I get error:
<ipython-input-3-5f18de09f6a1> in <module>()
----> 1 add.AsyncResult(a.task_id).get()
/home/t/py/django/celeryexample/venv/lib/python2.7/site-packages/celery/result.pyc in get(self, timeout, propagate, interval, no_ack, follow_parents, EXCEPTION_STATES, PROPAGATE_STATES)
167 interval=interval,
168 on_interval=on_interval,
--> 169 no_ack=no_ack,
170 )
171 if meta:
/home/t/py/django/celeryexample/venv/lib/python2.7/site-packages/celery/backends/base.pyc in _is_disabled(self, *args, **kwargs)
595 def _is_disabled(self, *args, **kwargs):
596 raise NotImplementedError(
--> 597 'No result backend configured. '
598 'Please see the documentation for more information.')
599 wait_for = get_status = get_result = get_traceback = _is_disabled
NotImplementedError: No result backend configured. Please see the documentation for more information
Upvotes: 0
Views: 4192
Reputation: 2178
pip install 'django_celery_results'
add django_celery_results in INSTALLED_APPS in settings.py(it will create one table to store result)
Set celery result as below in settings.py of your procject
CELERY_RESULT_BACKEND = 'django-db'
python manage.py makemigrations
python manage.py migrate
restart worker ..Done
Upvotes: 1
Reputation: 3092
You're getting this error because you're setting the backend to use a AMPQ compatible backing storage, which you don't have. Usual AMPQ storage is RabbitMQ but there are others like ActiveMQ, Apollo etc.
I recommend not to use AMPQ for persistence, unless you have a dedicated server.
You can instead use a database or redis for storing the results. For testing purposes you can use SQLite,
CELERY_RESULT_BACKEND = 'db+sqlite:///results.db'
From celery docs
Upvotes: 0