From cddd04974b0bb30fb8c5efccb3f1bc1ad4209885 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 4 Aug 2023 16:21:07 +0100 Subject: [PATCH] use walrus --- voicemeeterlib/remote.py | 5 +++-- voicemeeterlib/updater.py | 8 ++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/voicemeeterlib/remote.py b/voicemeeterlib/remote.py index 74e4d76..2c8495e 100644 --- a/voicemeeterlib/remote.py +++ b/voicemeeterlib/remote.py @@ -331,8 +331,9 @@ class Remote(CBindings): self.logger.info(f"Profile '{name}' applied!") def end_thread(self): - self.logger.debug("events thread shutdown started") - self.running = False + if self.running: + self.logger.debug("events thread shutdown started") + self.running = False def logout(self) -> None: """Logout of the API""" diff --git a/voicemeeterlib/updater.py b/voicemeeterlib/updater.py index a682555..b5f10ff 100644 --- a/voicemeeterlib/updater.py +++ b/voicemeeterlib/updater.py @@ -56,12 +56,7 @@ class Updater(threading.Thread): Generate _strip_comp, _bus_comp and update level cache if ldirty. """ - while True: - event = self.queue.get() - if event is None: - self.logger.debug(f"terminating {self.name} thread") - break - + while event := self.queue.get(): if event == "pdirty" and self._remote.pdirty: self._remote.subject.notify(event) elif event == "mdirty" and self._remote.mdirty: @@ -73,3 +68,4 @@ class Updater(threading.Thread): self._remote.cache["strip_level"] = self._remote._strip_buf self._remote.cache["bus_level"] = self._remote._bus_buf self._remote.subject.notify(event) + self.logger.debug(f"terminating {self.name} thread")