summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/tasks.txt30
-rw-r--r--docs/releases/6.1.txt4
2 files changed, 30 insertions, 4 deletions
diff --git a/docs/ref/tasks.txt b/docs/ref/tasks.txt
index 99d8eb6a0a..1850c91cab 100644
--- a/docs/ref/tasks.txt
+++ b/docs/ref/tasks.txt
@@ -17,10 +17,13 @@ Task definition
The ``task`` decorator
----------------------
-.. function:: task(*, priority=0, queue_name="default", backend="default", takes_context=False)
+.. function:: task(*, priority=0, queue_name="default", backend="default", takes_context=False, **kwargs)
- The ``@task`` decorator defines a :class:`Task` instance. This has the
- following optional arguments:
+ The ``@task`` decorator defines a :class:`Task` instance. All keyword
+ arguments are passed directly to the backend's ``task_class`` (which
+ defaults to :class:`Task`).
+
+ The following standard arguments are supported:
* ``priority``: Sets the :attr:`~Task.priority` of the ``Task``. Defaults
to 0.
@@ -32,6 +35,18 @@ The ``task`` decorator
:class:`TaskContext`. Defaults to ``False``. See :ref:`Task context
<task-context>` for details.
+ Custom Task backends may define a custom ``task_class`` that accepts
+ additional arguments. These can be passed through the ``@task`` decorator::
+
+ @task(foo=5, bar=600)
+ def my_task():
+ pass
+
+ .. versionchanged:: 6.1
+
+ Support for passing arbitrary ``**kwargs`` to the ``@task`` decorator
+ is added.
+
If the defined ``Task`` is not valid according to the backend,
:exc:`~django.tasks.exceptions.InvalidTask` is raised.
@@ -75,6 +90,8 @@ The ``task`` decorator
current time, a timezone-aware :class:`datetime <datetime.datetime>`,
or ``None`` if not constrained. Defaults to ``None``.
+ This attribute can be set using :meth:`~Task.using`.
+
The backend must have :attr:`.supports_defer` set to ``True`` to use
this feature. Otherwise,
:exc:`~django.tasks.exceptions.InvalidTask` is raised.
@@ -291,6 +308,13 @@ Base backend
``BaseTaskBackend`` is the parent class for all Task backends.
+ .. attribute:: BaseTaskBackend.task_class
+
+ The :class:`~django.tasks.Task` subclass to use when creating tasks
+ with the :func:`~django.tasks.task` decorator. Defaults to
+ :class:`~django.tasks.Task`. Custom backends can override this to use
+ a custom ``Task`` subclass with additional attributes.
+
.. attribute:: BaseTaskBackend.options
A dictionary of extra parameters for the Task backend. These are
diff --git a/docs/releases/6.1.txt b/docs/releases/6.1.txt
index 5dcdc9c50d..9c8aeea70c 100644
--- a/docs/releases/6.1.txt
+++ b/docs/releases/6.1.txt
@@ -348,7 +348,9 @@ Signals
Tasks
~~~~~
-* ...
+* The :func:`~django.tasks.task` decorator now accepts ``**kwargs``, which are
+ forwarded to the backend's
+ :attr:`~django.tasks.backends.base.BaseTaskBackend.task_class`.
Templates
~~~~~~~~~