I'm using Django, Celery and Redis to execute tasks.
# settings.py
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_APP = "my_app"
# tasks.py
@task(name="my_task", track_started = True)
def my_task():
time.sleep(5)
# Do stuff
return True
I call this task in 2 differents places in the application :
# test1.py
task = my_task.delay()
result = task.get()
print(result) # Shows True after 5 seconds
# test2.py
task = AsyncResult(my_task_id)
print(task.status) # Shows STARTED
print(task) # Shows the right id
result = task.get() # Get stuck here
print(result) # This line never appears in console
Of course, script in test1.py is called before test2.py. And I'm sure that id is correct. I don't have any messages in celery's log or in Django. It just get stuck.
I already tried solutions described here : Retrieve task result by id in Celery