Skip to content

Improve compliance with django.tasks spec#2

Open
RealOrangeOne wants to merge 5 commits intolincolnloop:mainfrom
RealOrangeOne:spec-compliance
Open

Improve compliance with django.tasks spec#2
RealOrangeOne wants to merge 5 commits intolincolnloop:mainfrom
RealOrangeOne:spec-compliance

Conversation

@RealOrangeOne
Copy link

This PR adds a few more features missing from django-tasks-local needed to be a compliant backend:

  • Call the correct signals. This also avoids the need for custom logging
  • Don't set supports_get_results, since they can't be obtained from other processes
  • Arguments should be JSON serializable, not simply picklable
  • Support takes_context, which avoids the need for the current_result_id context var
  • Set a worker id on results when executed

These simplify the implementation a fair bit, and support all the features of django.tasks.


(There's no formal spec, just docs)

Since the signals also handling logging, the custom logging can be
removed
`get_result` support requires that results can be obtained from any
thread or process.
The JSON requirement is already handled by TaskResult. Items which are
JSON serializable are all picklable.
fgregg added a commit to fgregg/django-tasks-local-db that referenced this pull request Mar 3, 2026
Adapt compliance improvements from lincolnloop/django-tasks-local#2:
- Send task_enqueued, task_started, task_finished signals
- Support takes_context tasks via TaskContext and task.call()
- Set worker ID via db_result.claim() in _execute_task
- Remove current_result_id ContextVar, pickle validation, and logger.exception
- Normalize return value in _execute_task instead of _on_complete

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant