From 5e5344845112e9e2bcd5d541e358d92d925e08ed Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sat, 26 Nov 2022 10:04:06 +0100 Subject: [PATCH] await on completed tasks, instead of calling .result() --- gui.py | 2 +- utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gui.py b/gui.py index 33acd6d..91a3f9c 100644 --- a/gui.py +++ b/gui.py @@ -1858,7 +1858,7 @@ class GUIManager: task.cancel() if self._close_requested.is_set(): raise ExitRequest() - return next(iter(done)).result() + return await next(iter(done)) def prevent_close(self): self._close_requested.clear() diff --git a/utils.py b/utils.py index 0a2d64a..373c014 100644 --- a/utils.py +++ b/utils.py @@ -46,7 +46,7 @@ async def first_to_complete(coros: abc.Iterable[abc.Coroutine[Any, Any, _T]]) -> done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED) for task in pending: task.cancel() - return next(iter(done)).result() + return await next(iter(done)) def chunk(to_chunk: abc.Iterable[_T], chunk_length: int) -> abc.Generator[list[_T], None, None]: