I'm using the Django ORM/Cache as the result backend for celery. I can see that django_celery_results_taskresult
table is created in the database. After the tasks are finished the results are also inserted in the database which can be viewed from MySQL. But when I try to access the results using AsyncResult
and task ID from django manage.py shell
I get the following error.
>>> AsyncResult.get('88e4d870-1a2b-4675-8f7c-1eacb7199bda')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/root/vms/lib/python3.6/site-packages/celery/result.py", line 199, in get
if self.ignored:
AttributeError: 'str' object has no attribute 'ignored'
>>> AsyncResult('88e4d870-1a2b-4675-8f7c-1eacb7199bda').get()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/root/vms/lib/python3.6/site-packages/celery/result.py", line 224, in get
on_message=on_message,
File "/root/vms/lib/python3.6/site-packages/celery/backends/base.py", line 470, in wait_for_pending
no_ack=no_ack,
File "/root/vms/lib/python3.6/site-packages/celery/backends/base.py", line 773, in _is_disabled
raise NotImplementedError(E_NO_BACKEND.strip())
NotImplementedError: No result backend is configured.
Please see the documentation for more information.
My celery.py
file is:
from __future__ import absolute_import, unicode_literals
from celery import Celery
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vms.settings')
app = Celery('vms', broker='redis://localhost', include=['cve.tasks','cpe.tasks'])
app.conf.update(
result_backend='django-db',
timezone = 'Asia/Kolkata'
)
if __name__ == '__main__':
app.start()
I've included django_celery_results
in settings.py
INSTALLED_APPLICATIONS
.
I find it weird that the results get inserted into the database but cannot be retrieved.
You have to import your app in order to access results. Try the following code in your shell:
from path.to.celery import app
app.AsyncResult('88e4d870-1a2b-4675-8f7c-1eacb7199bda')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With