Minor naming and comments update

This commit is contained in:
DevilXD committed 2022-08-19 10:19:23 +02:00
1 parent 5b1089e3cc
commit c682b75e2d
3 files changed
+12 -11

No files matched your search

+7 -7
View File
@@ -1621,7 +1621,7 @@ class GUIManager:
def __init__(self, twitch: Twitch):
self._twitch: Twitch = twitch
self._poll_task: asyncio.Task[NoReturn] | None = None
self._closed = asyncio.Event()
self._close_requested = asyncio.Event()
self._root = root = Tk()
# withdraw immediately to prevent the window from flashing
self._root.withdraw()
@@ -1744,14 +1744,14 @@ class GUIManager:
@property
def close_requested(self) -> bool:
return self._closed.is_set()
return self._close_requested.is_set()
async def wait_until_closed(self):
# wait until the user closes the window
await self._closed.wait()
await self._close_requested.wait()
def prevent_close(self):
self._closed.clear()
self._close_requested.clear()
def start(self):
if self._poll_task is None:
@@ -1783,12 +1783,12 @@ class GUIManager:
def close(self):
"""
Requests the application to close.
Requests the GUI application to close.
The window itself will be closed in the closing sequence later.
"""
self._closed.set()
self._close_requested.set()
# notify client we're supposed to close
self._twitch.request_close()
self._twitch.close()
def close_window(self):
"""
+2 -2
View File
@@ -160,8 +160,8 @@ exit_status = 0
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
client = Twitch(settings)
signal.signal(signal.SIGINT, lambda *_: client.close())
signal.signal(signal.SIGTERM, lambda *_: client.close())
signal.signal(signal.SIGINT, lambda *_: client.signal_close())
signal.signal(signal.SIGTERM, lambda *_: client.signal_close())
try:
loop.run_until_complete(client.run())
except CaptchaRequired:
+3 -2
View File
@@ -121,14 +121,15 @@ class Twitch:
# perfect for GUI usage
return partial(self.change_state, state)
def close(self):
def signal_close(self):
"""
Called when the application is requested to close by the operating system,
usually by receiving a SIGINT or SIGTERM.
"""
# delegate this to the same action as the user clicking on the X in the GUI window
self.gui.close()
def request_close(self):
def close(self):
"""
Called when the application is requested to close by the user,
usually by the console or application window being closed.