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
| Attribute | Type | Description |
|---|---|---|
| supports_defer | boolean = True | Boolean flag indicating that the backend supports deferred task execution. |
| supports_async_task | boolean = True | Boolean flag indicating that the backend supports asynchronous task processing. |
| supports_priority | boolean = True | Boolean flag indicating that the backend supports task prioritization. |
Constructor
Signature
def DummyBackend(
alias: string,
params: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| alias | string | The alias identifier for the backend instance. |
| params | dict | A 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
| Name | Type | Description |
|---|---|---|
| task | [Task](../../base/task.md?sid=django_tasks_base_task) | The task definition to be enqueued |
| args | tuple | Positional arguments to be passed to the task execution |
| kwargs | dict | Keyword arguments to be passed to the task execution |
Returns
| Type | Description |
|---|---|
[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
| Name | Type | Description |
|---|---|---|
| result_id | str | The 32-character unique identifier of the task result to retrieve |
Returns
| Type | Description |
|---|---|
[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
| Name | Type | Description |
|---|---|---|
| result_id | str | The 32-character unique identifier of the task result to retrieve |
Returns
| Type | Description |
|---|---|
[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
| Type | Description |
|---|---|
null |