Skip to main content

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

AttributeTypeDescription
supports_async_taskboolean = TrueBoolean flag indicating that this backend supports the execution of asynchronous tasks.
supports_priorityboolean = TrueBoolean flag indicating that this backend supports task prioritization.
worker_idstringA 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

NameTypeDescription
aliasAnyThe alias identifier for the backend instance.
paramsAnyA 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

NameTypeDescription
task[Task](../../base/task.md?sid=django_tasks_base_task)The task definition object to be executed.
argstuplePositional arguments to be passed to the task function during execution.
kwargsdictKeyword arguments to be passed to the task function during execution.

Returns

TypeDescription
[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.