Skip to content

Unfreeze tasks class #166

Description

@codingjoe

Code of Conduct

  • I agree to follow Django's Code of Conduct

Feature Description

Unfreezing tasks can improve versatility for custom task implementations and subclasses. Tasks are instantiated during module loading as quasi singletons. People can better use inheritance or even do in-place updates with decorators. Attribute read performance could be improved by slotting them.

Problem

Based on this forum discussion: https://forum.djangoproject.com/t/tasks-framework-versatility-performance/45035

TL;DR: Frozen dataclasses can't be easily modified during runtime. This is extra true for decorators. A practical example from django-crontask was that I wanted to attach the schedule to a task instance while being task backend/task agnostic.

cc @RealOrangeOne

Request or proposal

proposal

Additional Details

No response

Implementation Suggestions

While freezing task results makes sense architecturally (even though they are updated in place via refresh) the same argument doesn't extend to Task singletons. Freezing only makes it harder for people to go wild and build amazing things. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Idea

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions