rework the login timer loop.

patch bump
This commit is contained in:
onyx-and-iris 2023-10-27 23:21:40 +01:00
parent b360545aa6
commit 54dfa372b1
2 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "voicemeeter-api" name = "voicemeeter-api"
version = "2.5.0" version = "2.5.1"
description = "A Python wrapper for the Voiceemeter API" description = "A Python wrapper for the Voiceemeter API"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -75,20 +75,23 @@ class Remote(CBindings):
"Voicemeeter engine running but GUI not launched. Launching the GUI now." "Voicemeeter engine running but GUI not launched. Launching the GUI now."
) )
self.run_voicemeeter(self.kind.name) self.run_voicemeeter(self.kind.name)
err = None
start = time.time() start = time.time()
while True: while time.time() < start + self.timeout:
try: try:
time.sleep(0.1) # ensure at least 0.1 delay before clearing dirty time.sleep(0.1) # ensure at least 0.1 delay before clearing dirty
self.logger.info( self.logger.info(
f"{type(self).__name__}: Successfully logged into {self} version {self.version}" f"{type(self).__name__}: Successfully logged into {self} version {self.version}"
) )
elapsed = time.time() - start self.logger.debug(f"login time: {round(time.time() - start, 2)}")
self.logger.debug(f"login time: {round(elapsed, 2)}") err = None
break break
except CAPIError: except CAPIError as e:
if time.time() > start + self.timeout: err = e
raise VMError("Timeout logging into the api")
continue continue
if err:
raise VMError("Timeout logging into the api")
self.clear_dirty() self.clear_dirty()
def run_voicemeeter(self, kind_id: str) -> None: def run_voicemeeter(self, kind_id: str) -> None: