Question

For some reason, whenever I create and run a new Task in Celery there is a problem with returning the results. The first task returns perfectly, but for all subsequent tasks, the result is always pending. I checked the Celery log, and it gets the correct result with no errors, but it just can't return it.

If it helps, I am running rabbitmq as my backend.

Was it helpful?

Solution

Well it turns out I just needed to explicitly specify a backend.

Adding:

CELERY_RESULT_BACKEND = "amqp"

to my settings file seemed to fix everything.

OTHER TIPS

I am also getting the same issue even if I add 'amqp' backend.

Here is my celery config file:

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"

CELERY_RESULT_BACKEND = "amqp"
CELERY_AMQP_TASK_RESULT_EXPIRES = 18000  # 5 hours.
CELERY_IMPORTS = ("test", )

My shell where first time get is successful and second time its hung. After sometime if I call the method again it works. This pattern keeps repeating.

>>> r = test.add.delay(4, 4)
>>> r.get()
8
>>> r = test.add.delay(4, 4)
>>> r.get()
^C <---------- it was hung here forever, I had to press ^C

>>> r = test.add.delay(4, 4)
>>> r.get()
8
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top