asyncio.wait consistency cleanup

This commit is contained in:
DevilXD committed 2022-08-26 12:29:51 +02:00
1 parent 127822a26f
commit 8c031232d1
2 files changed
+6 -5

No files matched your search

+4 -3
View File
@@ -434,15 +434,16 @@ class LoginForm:
self._confirm.clear()
self._button.config(state="normal")
# NOTE: we need this to allow for the closing window event to break the waiting here
await asyncio.wait(
done, pending = await asyncio.wait(
[self._confirm.wait(), self._manager.wait_until_closed()],
return_when=asyncio.FIRST_COMPLETED,
)
for task in pending:
task.cancel()
if self._manager.close_requested:
raise ExitRequest()
self._button.config(state="disabled")
data = LoginData(self._login_entry.get(), self._pass_entry.get(), self._token_entry.get())
return data
return LoginData(self._login_entry.get(), self._pass_entry.get(), self._token_entry.get())
def update(self, status: str, user_id: int | None):
if user_id is not None:
+2 -2
View File
@@ -871,10 +871,10 @@ class Twitch:
[session.request(method, url, **kwargs), self.gui.wait_until_closed()],
return_when=asyncio.FIRST_COMPLETED,
)
if self.gui.close_requested:
raise ExitRequest()
for task in pending:
task.cancel()
if self.gui.close_requested:
raise ExitRequest()
for task in done:
response = task.result()
break