Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
Health listener: ignore a client that hangs up before the reply is written
YanissAmz97684a2d091b
diff --git a/tools/startup_health.py b/tools/startup_health.pyindex c8112d8..a3a072a 100644--- a/tools/startup_health.py+++ b/tools/startup_health.py@@ -177,14 +177,17 @@ class _EarlyServer:else:code, body = 503, LOADING_BODYdata = json.dumps(body).encode()- self.send_response(code)- self.send_header("Content-Type", "application/json")- self.send_header("Content-Length", str(len(data)))- self.send_header("Retry-After", "5")- self.send_header("Connection", "close")- self.end_headers()- if self.command != "HEAD":- self.wfile.write(data)+ try:+ self.send_response(code)+ self.send_header("Content-Type", "application/json")+ self.send_header("Content-Length", str(len(data)))+ self.send_header("Retry-After", "5")+ self.send_header("Connection", "close")+ self.end_headers()+ if self.command != "HEAD":+ self.wfile.write(data)+ except (BrokenPipeError, ConnectionResetError):+ pass # the client gave up (poll timeout): nothing to reportdo_GET = do_HEAD = do_POST = do_PUT = do_DELETE = _replydiff --git a/tools/test_startup_health.py b/tools/test_startup_health.pyindex 6941b56..b5819e4 100644--- a/tools/test_startup_health.py+++ b/tools/test_startup_health.py@@ -391,6 +391,28 @@ class ListenerTest(unittest.TestCase):self.assertEqual(codes, [503] * 8)+class QuietDisconnectTest(unittest.TestCase):+ def test_client_that_hangs_up_leaves_no_traceback(self):+ import contextlib+ import io+ t = tracker(["weights"], clock=Clock())+ t.serve("127.0.0.1", 0)+ buf = io.StringIO()+ try:+ with contextlib.redirect_stderr(buf):+ for _ in range(20):+ s = socket.create_connection(("127.0.0.1", t.server.port))+ s.sendall(b"GET /health HTTP/1.1\r\nHost: x\r\n\r\n")+ s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, b"\x01\x00\x00\x00\x00\x00\x00\x00")+ s.close() # reset before the reply is read+ time.sleep(0.3)+ code, _, _ = get(f"http://127.0.0.1:{t.server.port}/health")+ self.assertEqual(code, 503)+ finally:+ t.release_port()+ self.assertNotIn("Traceback", buf.getvalue())++class ForkTest(unittest.TestCase):def test_forked_child_does_not_keep_the_port(self):import os