Skip to content

Commit 5971625

Browse files
author
Anton
committed
fix: sync decorators
1 parent 49c0408 commit 5971625

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎taskiq/receiver/receiver.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,16 @@ async def run_task( # noqa: C901, PLR0912, PLR0915
267267
if timeout is not None:
268268
if not is_coroutine:
269269
logger.warning("Timeouts for sync tasks don't work in python well.")
270-
target_future = asyncio.wait_for(target_future, float(timeout))
271-
returned = await target_future
270+
271+
with anyio.fail_after(float(timeout)):
272+
while inspect.isawaitable(target_future):
273+
target_future = await target_future
274+
275+
else:
276+
while inspect.isawaitable(target_future):
277+
target_future = await target_future
278+
279+
returned = target_future
272280
except NoResultError as no_res_exc:
273281
found_exception = no_res_exc
274282
logger.warning(

0 commit comments

Comments
 (0)