Skip to content

Commit 7bc85e3

Browse files
warn user on dummy result backend level
1 parent 9ac6bf7 commit 7bc85e3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

taskiq/result_backends/dummy.py

Lines changed: 6 additions & 0 deletions
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

@@ -41,6 +45,8 @@ async def get_result(self, task_id: str, with_logs: bool = False) -> Any:
4145
:param with_logs: wether to fetch logs.
4246
:returns: TaskiqResult.
4347
"""
48+
logger.warning("No result backend configured. Returning dummy result...")
49+
4450
return TaskiqResult(
4551
is_err=False,
4652
log=None,

taskiq/task.py

Lines changed: 0 additions & 8 deletions
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)