From 4ea1c2ff4f7b33a26737a11a9aacc46cc335ed4c Mon Sep 17 00:00:00 2001 From: anti Date: Fri, 17 Apr 2026 15:43:51 -0400 Subject: [PATCH] fix(health): move Docker client+ping off the event loop Under CPU saturation the sync docker.from_env()/ping() calls could miss their socket timeout, cache _docker_healthy=False, and return 503 for the full 5s TTL window. Both calls now run on a thread so the event loop keeps serving other requests while Docker is being probed. --- decnet/web/router/health/api_get_health.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/decnet/web/router/health/api_get_health.py b/decnet/web/router/health/api_get_health.py index 95c9be0..f9bac90 100644 --- a/decnet/web/router/health/api_get_health.py +++ b/decnet/web/router/health/api_get_health.py @@ -102,8 +102,8 @@ async def get_health(user: dict = Depends(require_viewer)) -> Any: import docker if _docker_client is None: - _docker_client = docker.from_env() - _docker_client.ping() + _docker_client = await asyncio.to_thread(docker.from_env) + await asyncio.to_thread(_docker_client.ping) _docker_healthy = True _docker_detail = "" except Exception as exc: