django / django/new-features

Standardise Task execution order

Open
#188 3 comments 8 reactions 0 assignees View on GitHub
Django Core Tasks
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

I suggest defining exactly what the order of task execution should be.

### Problem

The currently implemented first-party Tasks backends don't behave as proper queues for executing tasks. Therefore, there's no canonical definition for the order that tasks should be executed in based on their attributes.

`django-tasks-db` has defined this as:

```python
[F("priority").desc(), F("run_after").asc(), F("enqueued_at").asc()]
```

(Defined as ORM fields for convenience).

### Request or proposal

proposal

### Additional Details

Some backends, such as RQ, do not support this level of customization for ordering. The standard should be best-effort, and adhered to as much as possible.

### Implementation Suggestions

I suggest taking the semantics from `django-tasks-db` and defining them as the standard execution order.

Following on from https://code.djangoproject.com/ticket/37126, this could be additionally defined as a sorting implementation for `TaskResult`, rather than just in documentation.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the django-tasks-db ordering semantics and the discussion in ticket 37126. Determine how the proposed priority, run_after, and enqueued_at order could be standardized, including best-effort behavior for backends such as RQ and possible TaskResult sorting. Done means the standard and its scope are agreed and documented or implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.