python 3.11 fixes

This commit is contained in:
Maxim Devaev
2023-05-04 12:37:05 +03:00
parent b5d6731497
commit b5353e63cd
8 changed files with 37 additions and 22 deletions

View File

@@ -202,7 +202,7 @@ async def wait_infinite() -> None:
await asyncio.sleep(3600)
async def wait_first(*aws: Awaitable) -> tuple[set[asyncio.Task], set[asyncio.Task]]:
async def wait_first(*aws: (asyncio.Future | asyncio.Task)) -> tuple[set[asyncio.Task], set[asyncio.Task]]:
return (await asyncio.wait(list(aws), return_when=asyncio.FIRST_COMPLETED))
@@ -242,7 +242,10 @@ class AioNotifier:
await self.__queue.get()
else:
try:
await asyncio.wait_for(self.__queue.get(), timeout=timeout)
await asyncio.wait_for(
asyncio.ensure_future(self.__queue.get()),
timeout=timeout,
)
except asyncio.TimeoutError:
return # False
while not self.__queue.empty():