Fix asyncio.wait breaking in Python 3.11
This commit is contained in:
1 parent
f50d02ed0b
commit
683d2fd755
1 file changed
+4
-1
@@ -1923,8 +1923,11 @@ class GUIManager:
|
|||||||
await self._close_requested.wait()
|
await self._close_requested.wait()
|
||||||
|
|
||||||
async def coro_unless_closed(self, coro: abc.Awaitable[_T]) -> _T:
|
async def coro_unless_closed(self, coro: abc.Awaitable[_T]) -> _T:
|
||||||
|
# In Python 3.11, we need to explicitly wrap awaitables
|
||||||
|
future: asyncio.Future[_T] = asyncio.ensure_future(coro)
|
||||||
|
done: set[asyncio.Task[Any]]
|
||||||
done, pending = await asyncio.wait(
|
done, pending = await asyncio.wait(
|
||||||
[coro, self._close_requested.wait()],
|
[future, self._close_requested.wait()],
|
||||||
return_when=asyncio.FIRST_COMPLETED,
|
return_when=asyncio.FIRST_COMPLETED,
|
||||||
)
|
)
|
||||||
for task in pending:
|
for task in pending:
|
||||||
|
|||||||
Reference in new issue
Block a user