mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 01:21:43 +00:00
Merge 9d143fb66d into 13038dc747
This commit is contained in:
commit
d4b3ed6e6b
1 changed files with 12 additions and 1 deletions
|
|
@ -2709,14 +2709,25 @@ class GatewayRunner:
|
||||||
|
|
||||||
self._finalize_shutdown_agents(active_agents)
|
self._finalize_shutdown_agents(active_agents)
|
||||||
|
|
||||||
|
# Disconnect adapters with per-adapter timeout to prevent hangs.
|
||||||
|
# A stuck adapter (e.g., Feishu WebSocket thread waiting for network
|
||||||
|
# I/O) should not block the entire shutdown sequence and prevent
|
||||||
|
# PID file cleanup, which would cause "PID file race lost" errors
|
||||||
|
# on restart after systemd SIGKILL's the process.
|
||||||
|
_adapter_disconnect_timeout = 15.0 # seconds per adapter
|
||||||
for platform, adapter in list(self.adapters.items()):
|
for platform, adapter in list(self.adapters.items()):
|
||||||
try:
|
try:
|
||||||
await adapter.cancel_background_tasks()
|
await adapter.cancel_background_tasks()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug("✗ %s background-task cancel error: %s", platform.value, e)
|
logger.debug("✗ %s background-task cancel error: %s", platform.value, e)
|
||||||
try:
|
try:
|
||||||
await adapter.disconnect()
|
await asyncio.wait_for(adapter.disconnect(), timeout=_adapter_disconnect_timeout)
|
||||||
logger.info("✓ %s disconnected", platform.value)
|
logger.info("✓ %s disconnected", platform.value)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
logger.warning(
|
||||||
|
"✗ %s disconnect timed out after %.1fs - forcing continue",
|
||||||
|
platform.value, _adapter_disconnect_timeout
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("✗ %s disconnect error: %s", platform.value, e)
|
logger.error("✗ %s disconnect error: %s", platform.value, e)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue