Skip to content

Commit 0ed6d68

Browse files
committedMar 23, 2025
warn user on dummy result backend level
1 parent 9ac6bf7 commit 0ed6d68

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed
 

‎taskiq/result_backends/dummy.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from logging import getLogger
12
from typing import Any, TypeVar
23

34
from taskiq.abc.result_backend import AsyncResultBackend
@@ -6,6 +7,9 @@
67
_ReturnType = TypeVar("_ReturnType")
78

89

10+
logger = getLogger("taskiq")
11+
12+
913
class DummyResultBackend(AsyncResultBackend[_ReturnType]): # pragma: no cover
1014
"""Default result backend, that does nothing."""
1115

@@ -18,6 +22,7 @@ async def set_result(self, task_id: str, result: Any) -> None:
1822
:param task_id: current task id.
1923
:param result: result of execution.
2024
"""
25+
logger.warning("No result backend configured. Results will not be stored.")
2126

2227
async def is_result_ready(self, task_id: str) -> bool:
2328
"""
@@ -41,6 +46,8 @@ async def get_result(self, task_id: str, with_logs: bool = False) -> Any:
4146
:param with_logs: wether to fetch logs.
4247
:returns: TaskiqResult.
4348
"""
49+
logger.warning("No result backend configured. Returning dummy result...")
50+
4451
return TaskiqResult(
4552
is_err=False,
4653
log=None,

‎taskiq/task.py

-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
from logging import getLogger
32
from time import time
43
from typing import TYPE_CHECKING, Any, Generic, Optional
54

@@ -10,7 +9,6 @@
109
ResultIsReadyError,
1110
TaskiqResultTimeoutError,
1211
)
13-
from taskiq.result_backends.dummy import DummyResultBackend
1412

1513
if TYPE_CHECKING: # pragma: no cover
1614
from taskiq.abc.result_backend import AsyncResultBackend
@@ -20,9 +18,6 @@
2018
_ReturnType = TypeVar("_ReturnType")
2119

2220

23-
logger = getLogger("taskiq")
24-
25-
2621
class AsyncTaskiqTask(Generic[_ReturnType]):
2722
"""AsyncTask for AsyncResultBackend."""
2823

@@ -88,9 +83,6 @@ async def wait_result(
8883
become ready in provided period of time.
8984
:return: task's return value.
9085
"""
91-
if isinstance(self.result_backend, DummyResultBackend):
92-
logger.warning("No result backend configured. Returning dummy result...")
93-
9486
start_time = time()
9587
while not await self.is_ready():
9688
await asyncio.sleep(check_interval)

0 commit comments

Comments
 (0)
Failed to load comments.