fix(tui_gateway): guard env var parsing against invalid values at import
_SLASH_WORKER_TIMEOUT_S and _pool used raw float()/int() on env vars at module level. A non-numeric value (e.g. HERMES_TUI_SLASH_TIMEOUT_S=abc) raises ValueError during import, preventing TUI gateway from starting with no useful error message. Wrap both parses in try/except with safe fallbacks: - HERMES_TUI_SLASH_TIMEOUT_S: fallback to 45.0s - HERMES_TUI_RPC_POOL_WORKERS: fallback to 4 workers
This commit is contained in:
parent
531ac20408
commit
5ed27c0f74
@ -125,9 +125,11 @@ _cfg_lock = threading.Lock()
|
||||
_cfg_cache: dict | None = None
|
||||
_cfg_mtime: float | None = None
|
||||
_cfg_path = None
|
||||
_SLASH_WORKER_TIMEOUT_S = max(
|
||||
5.0, float(os.environ.get("HERMES_TUI_SLASH_TIMEOUT_S", "45") or 45)
|
||||
)
|
||||
try:
|
||||
_slash_timeout = float(os.environ.get("HERMES_TUI_SLASH_TIMEOUT_S") or "45")
|
||||
except (ValueError, TypeError):
|
||||
_slash_timeout = 45.0
|
||||
_SLASH_WORKER_TIMEOUT_S = max(5.0, _slash_timeout)
|
||||
_DETAIL_SECTION_NAMES = ("thinking", "tools", "subagents", "activity")
|
||||
_DETAIL_MODES = frozenset({"hidden", "collapsed", "expanded"})
|
||||
|
||||
@ -153,8 +155,12 @@ _LONG_HANDLERS = frozenset(
|
||||
}
|
||||
)
|
||||
|
||||
try:
|
||||
_rpc_pool_workers = max(2, int(os.environ.get("HERMES_TUI_RPC_POOL_WORKERS") or "4"))
|
||||
except (ValueError, TypeError):
|
||||
_rpc_pool_workers = 4
|
||||
_pool = concurrent.futures.ThreadPoolExecutor(
|
||||
max_workers=max(2, int(os.environ.get("HERMES_TUI_RPC_POOL_WORKERS", "4") or 4)),
|
||||
max_workers=_rpc_pool_workers,
|
||||
thread_name_prefix="tui-rpc",
|
||||
)
|
||||
atexit.register(lambda: _pool.shutdown(wait=False, cancel_futures=True))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user