task
Decorates a function to register it as a background task using a specified backend, priority, and queue name.
def task(
function: callable = null,
priority: int = DEFAULT_TASK_PRIORITY,
queue_name: string = DEFAULT_TASK_QUEUE_NAME,
backend: string = DEFAULT_TASK_BACKEND_ALIAS,
takes_context: boolean = false,
**kwargs: dict
) - > Task
Decorates a function to register it as an asynchronous task within a specified backend and queue.
Parameters
| Name | Type | Description |
|---|---|---|
| function | callable = null | The function to be converted into an asynchronous task. |
| priority | int = DEFAULT_TASK_PRIORITY | The execution priority level assigned to the task. |
| queue_name | string = DEFAULT_TASK_QUEUE_NAME | The name of the queue where the task will be dispatched for execution. |
| backend | string = DEFAULT_TASK_BACKEND_ALIAS | The alias of the task backend responsible for processing the task. |
| takes_context | boolean = false | Indicates whether the task function expects the execution context as its first argument. |
| **kwargs | dict | Additional configuration options for the task backend; note that 'run_after' is not permitted. |
Returns
| Type | Description |
|---|---|
Task | A task instance wrapping the original function, or a decorator function if used without arguments. |