pluggable TaskResultStatus

Hi everyone,

I’m not sure if this is the right place to ask, but I’ll give it a try.

I’m experimenting with the new Tasks framework introduced in Django 6.0, and I’ve run into an issue with the TaskResultStatus object: it only provides four possible states, and there doesn’t seem to be any way to extend it other than through monkey-patching, which doesn’t feel like a good solution.

This is particularly limiting because, in real-world scenarios, there may be many more states. For example:

  • a task might be cancelled before execution;
  • a worker might start processing a task but fail to properly report its execution status.

What would be the recommended way to add additional states?

Making the public API pluggable isn’t really the intention. The problem being that if your backend defines additional statuses, it’s now not as pluggable.

Currently, the API doesn’t have fully-defined semantics for cancelling tasks at all, nor any way to track any issues with reporting status.

The RQ backend, which does support cancelling, maps these tasks to failed. You can use the internal APIs to retrieve the raw RQ status, but Django maps it to ones which can be fully supported.