Skip to content

Commit 668d878

Browse files
committed
chore: fix warning about deprecated asyncio.iscoroutinefunction usage
1 parent 5059895 commit 668d878

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

taskiq/receiver/receiver.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import contextvars
33
import functools
44
import inspect
5+
import sys
56
from collections.abc import Callable
67
from concurrent.futures import Executor
78
from logging import getLogger
@@ -23,6 +24,7 @@
2324
from taskiq.utils import maybe_awaitable
2425

2526
logger = getLogger(__name__)
27+
PY_VERSION = sys.version_info
2628
QUEUE_DONE = b"-1"
2729

2830

@@ -224,6 +226,11 @@ async def run_task( # noqa: C901, PLR0912, PLR0915
224226
# Start a timer.
225227
start_time = time()
226228

229+
check_coroutine_func = (
230+
asyncio.iscoroutinefunction
231+
if PY_VERSION <= (3, 13)
232+
else inspect.iscoroutinefunction
233+
)
227234
try:
228235
# We put kwargs resolving here,
229236
# to be able to catch any exception (for example ),
@@ -234,7 +241,7 @@ async def run_task( # noqa: C901, PLR0912, PLR0915
234241
kwargs.update(message.kwargs)
235242
is_coroutine = True
236243
# If the function is a coroutine, we await it.
237-
if asyncio.iscoroutinefunction(target):
244+
if check_coroutine_func(target):
238245
target_future = target(*message.args, **kwargs)
239246
else:
240247
is_coroutine = False

0 commit comments

Comments
 (0)