From 8c031232d1959e18294d7fa8b6b6398e0b53abf4 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Fri, 26 Aug 2022 12:29:51 +0200 Subject: [PATCH] asyncio.wait consistency cleanup --- gui.py | 7 ++++--- twitch.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gui.py b/gui.py index 77a818a..c6e0385 100644 --- a/gui.py +++ b/gui.py @@ -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: diff --git a/twitch.py b/twitch.py index a3b9df6..ffc044b 100644 --- a/twitch.py +++ b/twitch.py @@ -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