Metadata-Version: 2.5
Name: django-spec-tasks
Version: 0.1.0
Summary: Run a django-service-specs spec as a background task: a durable run record, and a worker that re-checks through dispatch.
Project-URL: Homepage, https://github.com/Artui/django-spec-tasks
Project-URL: Repository, https://github.com/Artui/django-spec-tasks
Project-URL: Issues, https://github.com/Artui/django-spec-tasks/issues
Author-email: Artur Veres <artur8118@gmail.com>
License: MIT
License-File: LICENSE
Keywords: background-tasks,celery,dispatch,django,django-tasks,services,specs
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Framework :: Django :: 6.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: django-service-specs>=0.29.0
Requires-Dist: django>=4.2
Provides-Extra: celery
Requires-Dist: celery>=5.6; extra == 'celery'
Provides-Extra: django-tasks
Requires-Dist: django-tasks>=0.12.0; extra == 'django-tasks'
Description-Content-Type: text/markdown

# django-spec-tasks

[![CI](https://github.com/Artui/django-spec-tasks/workflows/tests/badge.svg)](https://github.com/Artui/django-spec-tasks/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/django-spec-tasks.svg)](https://pypi.org/project/django-spec-tasks/)
[![Python versions](https://img.shields.io/pypi/pyversions/django-spec-tasks.svg)](https://pypi.org/project/django-spec-tasks/)
[![Django versions](https://img.shields.io/pypi/djversions/django-spec-tasks.svg)](https://pypi.org/project/django-spec-tasks/)
[![Docs](https://img.shields.io/badge/docs-artui.github.io-blue.svg)](https://artui.github.io/django-spec-tasks/)
[![Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Artui/django-spec-tasks/gh-pages/coverage.json)](https://github.com/Artui/django-spec-tasks/actions/workflows/tests.yml)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![License](https://img.shields.io/pypi/l/django-spec-tasks.svg)](https://github.com/Artui/django-spec-tasks/blob/main/LICENSE)

Run a [django-service-specs](https://github.com/Artui/django-service-specs) spec as a background task:
a durable run record, and a worker that re-checks through `dispatch`.

```bash
pip install "django-spec-tasks[celery]"        # or
pip install "django-spec-tasks[django-tasks]"  # the backport, below Django 6.0
```

```python
from django_spec_tasks import TaskBinding, enqueue, read_run
from django_spec_tasks.backends.celery_backend import CeleryBackend

orders = TaskBinding(name="orders", registry=order_specs, backend=CeleryBackend())

run_id = enqueue(orders, "refund_order", {"order": "7"}, actor=request.user)
status = read_run(orders, run_id, request.user)
```

The queue decides where the code runs; the row decides whether it ran. A backend may lose a message or deliver
it twice without consequence, which is what lets one protocol hold Celery and Django Tasks.

Read [the documentation](https://artui.github.io/django-spec-tasks/).
