Posts

Showing posts with the label django-celery

Celery get() works in python shell but not in Django view

Image
Clash Royale CLAN TAG #URR8PPP Celery get() works in python shell but not in Django view I want to check basic Celery functionality inside official demo Celery project for django with code available here. My modification is the demoapp/views.py (and of course urls.py to point to this view): from __future__ import absolute_import, unicode_literals from django.http import HttpResponse from demoapp.tasks import add, mul, xsum def home(request): return HttpResponse("Your output is: %s" % mul.delay(22,4).get(timeout=1) ) which always gives timeout error, though the terminal of running Celery worker shows that task was received and displays correct return value. However, if I start python shell python ./manage.py shell and then run python ./manage.py shell from demoapp.tasks import add, mul, xsum mul.delay(22,4).get(timeout=1) I immediately get the expected result. What may be the problem? Rabbitmq server is running, I use Celery 4.2.1, django 2.0.6. demoapp/tasks.py: from __f...