diff --git a/taskiq/receiver/receiver.py b/taskiq/receiver/receiver.py index 853ed24..c9d5c24 100644 --- a/taskiq/receiver/receiver.py +++ b/taskiq/receiver/receiver.py @@ -269,11 +269,13 @@ async def run_task( # noqa: C901, PLR0912, PLR0915 logger.warning("Timeouts for sync tasks don't work in python well.") with anyio.fail_after(float(timeout)): - while inspect.isawaitable(target_future): + target_future = await target_future + if inspect.isawaitable(target_future): target_future = await target_future else: - while inspect.isawaitable(target_future): + target_future = await target_future + if inspect.isawaitable(target_future): target_future = await target_future returned = target_future