ImmediateBackend
This class provides a task backend implementation that executes tasks synchronously and immediately upon enqueueing. It manages the full task lifecycle, including status updates, error handling, and signal dispatching, without the need for an external worker process. The backend supports both asynchronous task definitions and task prioritization while ensuring results are captured and normalized.
Attributes
| Attribute | Type | Description |
|---|---|---|
| supports_async_task | boolean = True | Boolean flag indicating that this backend supports the execution of asynchronous tasks. |
| supports_priority | boolean = True | Boolean flag indicating that this backend supports task prioritization. |
| worker_id | string | A unique 32-character random string used to identify the specific backend instance during task execution. |
Constructor
Signature
def ImmediateBackend(
alias: Any,
params: Any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| alias | Any | The alias identifier for the backend instance. |
| params | Any | A dictionary or object containing configuration parameters for the backend. |
Methods
enqueue()
@classmethod
def enqueue(
task: [Task](../../base/task.md?sid=django_tasks_base_task),
args: tuple,
kwargs: dict
) - > [TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult)
Validates and immediately executes a task in the current process, bypassing any asynchronous queueing mechanism.
Parameters
| Name | Type | Description |
|---|---|---|
| task | [Task](../../base/task.md?sid=django_tasks_base_task) | The task definition object to be executed. |
| args | tuple | Positional arguments to be passed to the task function during execution. |
| kwargs | dict | Keyword arguments to be passed to the task function during execution. |
Returns
| Type | Description |
|---|---|
[TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult) | A TaskResult object containing the final execution status, return value, or error details of the completed task. |