asyncio.wait consistency cleanup
This commit is contained in:
1 parent
127822a26f
commit
8c031232d1
2 files changed
+6
-5
No files matched your search
@@ -434,15 +434,16 @@ class LoginForm:
|
|||||||
self._confirm.clear()
|
self._confirm.clear()
|
||||||
self._button.config(state="normal")
|
self._button.config(state="normal")
|
||||||
# NOTE: we need this to allow for the closing window event to break the waiting here
|
# 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()],
|
[self._confirm.wait(), self._manager.wait_until_closed()],
|
||||||
return_when=asyncio.FIRST_COMPLETED,
|
return_when=asyncio.FIRST_COMPLETED,
|
||||||
)
|
)
|
||||||
|
for task in pending:
|
||||||
|
task.cancel()
|
||||||
if self._manager.close_requested:
|
if self._manager.close_requested:
|
||||||
raise ExitRequest()
|
raise ExitRequest()
|
||||||
self._button.config(state="disabled")
|
self._button.config(state="disabled")
|
||||||
data = LoginData(self._login_entry.get(), self._pass_entry.get(), self._token_entry.get())
|
return LoginData(self._login_entry.get(), self._pass_entry.get(), self._token_entry.get())
|
||||||
return data
|
|
||||||
|
|
||||||
def update(self, status: str, user_id: int | None):
|
def update(self, status: str, user_id: int | None):
|
||||||
if user_id is not None:
|
if user_id is not None:
|
||||||
|
|||||||
@@ -871,10 +871,10 @@ class Twitch:
|
|||||||
[session.request(method, url, **kwargs), self.gui.wait_until_closed()],
|
[session.request(method, url, **kwargs), self.gui.wait_until_closed()],
|
||||||
return_when=asyncio.FIRST_COMPLETED,
|
return_when=asyncio.FIRST_COMPLETED,
|
||||||
)
|
)
|
||||||
if self.gui.close_requested:
|
|
||||||
raise ExitRequest()
|
|
||||||
for task in pending:
|
for task in pending:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
if self.gui.close_requested:
|
||||||
|
raise ExitRequest()
|
||||||
for task in done:
|
for task in done:
|
||||||
response = task.result()
|
response = task.result()
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user