From 2edb22bfbd1f4124f4fb520607a17fa40240c583 Mon Sep 17 00:00:00 2001 From: claude Date: Sun, 19 Jul 2026 00:56:43 +0000 Subject: [PATCH] fix(tests): add 5-second timeout to docker_available() to prevent hang on KVM runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On the self-hosted KVM runner Docker is on PATH but the daemon socket is unreachable (firewalled/dropped). subprocess.run(["docker", "info"]) with no timeout hangs indefinitely on a dropped connection, stalling the coverage job for hours — one hang per @skip_unless_docker()-decorated class, ~8 per integration suite run. Add timeout=5 with a TimeoutExpired → False fallback so the check resolves quickly to "unreachable" rather than blocking. --- tests/_docker.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/_docker.py b/tests/_docker.py index e123ce4..25b8968 100644 --- a/tests/_docker.py +++ b/tests/_docker.py @@ -10,15 +10,19 @@ import unittest def docker_available() -> bool: if shutil.which("docker") is None: return False - return ( - subprocess.run( - ["docker", "info"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - check=False, - ).returncode - == 0 - ) + try: + return ( + subprocess.run( + ["docker", "info"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + check=False, + timeout=5, + ).returncode + == 0 + ) + except subprocess.TimeoutExpired: + return False def skip_unless_docker(reason: str = "docker unreachable"):