Search code examples
pythonrediscelery

AsyncResult returns None if task completed successfully


I'm currently working on a system where i have a processing component that uses celery to distribute tasks to workers and a backend where you can check the status of longer running tasks.

I followed this example and everything works as expected. You can schedule tasks and while the task is running, you can see its status. However after the task is complete, it only works if the task finished with an error. If the task finished with success, AsyncResult returns a None type while the tombstone is still alive, which to my best knowledge is undocumented behaviour. After the tombstone has expired and the task_id is no longer known to celery, it once again returns a PENDING status, which is expected.

I'm using redis as result backend, if that makes any difference.

Any ideas why i'm getting a None type return for successful tasks?


Solution

  • The error was actually my own, as in the API call that gets the status of the task, I try to get task.info. Since my task did not return anything upon completion, task.info was None.

    Fixed my mistake and now it works.