From 54dfa372b162e0e128d75b2082a4fb4ed74dbcc5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 27 Oct 2023 23:21:40 +0100 Subject: [PATCH] rework the login timer loop. patch bump --- pyproject.toml | 2 +- voicemeeterlib/remote.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dfb16f6..d08e31f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "voicemeeter-api" -version = "2.5.0" +version = "2.5.1" description = "A Python wrapper for the Voiceemeter API" authors = ["onyx-and-iris "] license = "MIT" diff --git a/voicemeeterlib/remote.py b/voicemeeterlib/remote.py index 7e45f0e..18f883a 100644 --- a/voicemeeterlib/remote.py +++ b/voicemeeterlib/remote.py @@ -75,20 +75,23 @@ class Remote(CBindings): "Voicemeeter engine running but GUI not launched. Launching the GUI now." ) self.run_voicemeeter(self.kind.name) + + err = None start = time.time() - while True: + while time.time() < start + self.timeout: try: time.sleep(0.1) # ensure at least 0.1 delay before clearing dirty self.logger.info( f"{type(self).__name__}: Successfully logged into {self} version {self.version}" ) - elapsed = time.time() - start - self.logger.debug(f"login time: {round(elapsed, 2)}") + self.logger.debug(f"login time: {round(time.time() - start, 2)}") + err = None break - except CAPIError: - if time.time() > start + self.timeout: - raise VMError("Timeout logging into the api") + except CAPIError as e: + err = e continue + if err: + raise VMError("Timeout logging into the api") self.clear_dirty() def run_voicemeeter(self, kind_id: str) -> None: