improved logging

This commit is contained in:
Ayzen
2026-06-06 00:52:52 +03:00
parent af6005d68f
commit aea49f6128
65 changed files with 1206 additions and 240 deletions
@@ -44,7 +44,18 @@ class GeneratorController:
timeout_s: float,
poll_interval_s: float,
) -> DeviceStatus:
"""Wait until available lock flags report the generator is ready."""
"""Poll device status until the source/LO lock flags report the generator
is ready, then return that status.
Polls every ``poll_interval_s`` seconds up to ``timeout_s`` total. Raises
``TimeoutError`` if the locks do not assert in time and ``RuntimeError`` if
the connected hardware family exposes no lock telemetry.
"""
logger.info(
"Waiting for generator lock (timeout=%.2fs, poll_interval=%.2fs)",
timeout_s,
poll_interval_s,
)
deadline = time.monotonic() + timeout_s
@@ -53,13 +64,19 @@ class GeneratorController:
lock_values = [value for value in (status.source_locked, status.lo_locked) if value is not None]
if lock_values:
if all(lock_values):
logger.info("Generator locked (family=%s)", status.family.name)
return status
else:
logger.error(
"Generator lock telemetry unavailable for hardware family %s",
status.family.name,
)
raise RuntimeError(
f"Generator lock telemetry is unavailable for hardware family {status.family.name}"
)
remaining = deadline - time.monotonic()
if remaining <= 0:
logger.warning("Timed out waiting for generator lock after %.2fs", timeout_s)
raise TimeoutError("Timed out waiting for LibreVNA generator lock")
time.sleep(min(poll_interval_s, remaining))