mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-22 11:00:47 +00:00
adds a configurable timeout for login()
readme, changelog updated fixes #9
This commit is contained in:
parent
4bfc32ad91
commit
b360545aa6
@ -11,6 +11,13 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
||||
|
||||
- [x]
|
||||
|
||||
## [2.5.0]
|
||||
|
||||
### Fixed
|
||||
|
||||
- {Remote}.login() now has a configuratble timeout. Use timeout kwarg to set it. Defaults to 2 seconds.
|
||||
- Remote class section in README updated to include timeout kwarg.
|
||||
|
||||
## [2.4.8] - 2023-08-13
|
||||
|
||||
### Added
|
||||
|
@ -812,6 +812,7 @@ You may pass the following optional keyword arguments:
|
||||
- `mdirty`: boolean=False, macrobutton updates
|
||||
- `midi`: boolean=False, midi updates
|
||||
- `ldirty`: boolean=False, level updates
|
||||
- `timeout`: float=2.0, maximum time to wait for a successful login in seconds
|
||||
|
||||
Access to lower level Getters and Setters are provided with these functions:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "voicemeeter-api"
|
||||
version = "2.4.13"
|
||||
version = "2.5.0"
|
||||
description = "A Python wrapper for the Voiceemeter API"
|
||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||
license = "MIT"
|
||||
|
@ -114,6 +114,7 @@ class FactoryBase(Remote):
|
||||
"mdirty": False,
|
||||
"midi": False,
|
||||
"ldirty": False,
|
||||
"timeout": 2,
|
||||
}
|
||||
if "subs" in kwargs:
|
||||
defaultkwargs |= kwargs.pop("subs") # for backwards compatibility
|
||||
|
@ -75,11 +75,21 @@ class Remote(CBindings):
|
||||
"Voicemeeter engine running but GUI not launched. Launching the GUI now."
|
||||
)
|
||||
self.run_voicemeeter(self.kind.name)
|
||||
time.sleep(0.1)
|
||||
self.clear_dirty()
|
||||
start = time.time()
|
||||
while True:
|
||||
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)}")
|
||||
break
|
||||
except CAPIError:
|
||||
if time.time() > start + self.timeout:
|
||||
raise VMError("Timeout logging into the api")
|
||||
continue
|
||||
self.clear_dirty()
|
||||
|
||||
def run_voicemeeter(self, kind_id: str) -> None:
|
||||
if kind_id not in (kind.name.lower() for kind in KindId):
|
||||
@ -89,7 +99,6 @@ class Remote(CBindings):
|
||||
else:
|
||||
value = KindId[kind_id.upper()].value
|
||||
self.call(self.bind_run_voicemeeter, value)
|
||||
time.sleep(1)
|
||||
|
||||
@property
|
||||
def type(self) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user