Skip to main content

DummyBackend

This class provides a simplified task backend implementation primarily used for testing or local development environments. It supports task features such as deferral, asynchronous execution, and priority while storing task results in an in-memory list. The backend allows for basic result retrieval and clearing, though results are scoped to the current execution context.

Attributes

AttributeTypeDescription
supports_deferboolean = TrueBoolean flag indicating that the backend supports deferred task execution.
supports_async_taskboolean = TrueBoolean flag indicating that the backend supports asynchronous task processing.
supports_priorityboolean = TrueBoolean flag indicating that the backend supports task prioritization.

Constructor

Signature

def DummyBackend(
alias: string,
params: dict
) - > null

Parameters

NameTypeDescription
aliasstringThe alias identifier for the backend instance.
paramsdictA dictionary of 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)

Creates a new TaskResult in a READY state, stores it in the backend, and returns a deep copy to the caller.

Parameters

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

Returns

TypeDescription
[TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult)A deep copy of the initialized TaskResult object to prevent mutation of the stored state

get_result()

@classmethod
def get_result(
result_id: str
) - > [TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult)

Retrieves a specific task result from the in-memory list based on its unique identifier.

Parameters

NameTypeDescription
result_idstrThe 32-character unique identifier of the task result to retrieve

Returns

TypeDescription
[TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult)The matching TaskResult object found in the local store

aget_result()

@classmethod
def aget_result(
result_id: str
) - > [TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult)

Asynchronously retrieves a specific task result from the in-memory list based on its unique identifier.

Parameters

NameTypeDescription
result_idstrThe 32-character unique identifier of the task result to retrieve

Returns

TypeDescription
[TaskResult](../../base/taskresult.md?sid=django_tasks_base_taskresult)The matching TaskResult object found in the local store

clear()

@classmethod
def clear() - > null

Flushes all stored task results from the backend's internal memory.

Returns

TypeDescription
null