django-tasks - bringing background workers in to Django core

django-tasks is an accepted Enhancement Proposal to bring background workers into Django itself (as django.tasks). Introducing both a common API contract for developers and library authors (eg django.core.cache), but also a production-grade ORM-based worker and queue.

I gave a talk at Djangocon Europe last month introducing it:

Now, I need your help testing it, finding the issues, and adding features. The aim is to get it merged into Django 5.2 (April 2025, but the merge deadline is December 2024), and there’s a lot still to do between now and then.

Give it a try, see how it works, and let me know what you think!

12 Likes

Hello! I saw your video and decided to come here to ask about it. Are you looking to eventually be able to interface with Celery or similar worker providers like RQ using the consistent django-tasks (or similarly named) API? I wasn’t exactly sure from the video whether that’s the ultimate goal is to interface with the existing systems or to simply replace most use-cases with a DB-backed system.

I’d like interops between existing implementations, yes. When and who writes them is still TBC. There’s a Celery backend in progress.

These will absolutely be in Django core, as it’s too much maintenance burden.

The DB backend will definitely be in Django core. Redis might come later to core, but that’s not my decision to make. django-tasks will likely live on to contain the components which don’t make sense in Django core, and as a testing ground before integrating.

1 Like

The first PR, implementing the core API for background workers is up for review :tada: !

The notable omission is the database worker. This exists in django-tasks, but in the interest of easier review, isn’t in the first PR. It’ll come later, once the core is merged.

Any and all review appreciated!

1 Like

thank you very much for the great work. Meanwhile, when the ticket is not yet merged, my question is, can I start using django-tasks as a separate module and later remove django-tasks when it is available as part of the Django’s core without any code changes?
Cheers,
Alex

ā€œwithout any code changesā€ is a very strong phrase. No, you can’t do it without any, but it should be minimal at best. As an application developer, it should be a case of swapping out the task backend in TASKS, and changing where you import the task decorator from. Everything else should ā€œjust workā€ :tm:

Exactly how a project will behave with both installed, I don’t know. In theory the APIs are the same, so assuming they have the same backend, each package’s task decorator shouldn’t conflict.

1 Like