Skip to content

Standardise Task execution order #188

Description

@RealOrangeOne

Code of Conduct

  • 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:

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Django CoreThis idea is suitable for inclusion in Django itself.Tasks

    Type

    No type

    Projects

    Status
    Idea

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions