From d2ab08a5f5def244cd05ddccd2b46bdaaf8f177e Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 2 Nov 2026 04:41:26 -0800 Subject: [PATCH] MLX proxy: don't count health checks as requests Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca --- llmhost/backends/mlx.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/llmhost/backends/mlx.py b/llmhost/backends/mlx.py index 675d560..b6b2481 100644 --- a/llmhost/backends/mlx.py +++ b/llmhost/backends/mlx.py @@ -102,9 +102,11 @@ def make_handler(inner_port, served_name, context, key, stats): self._forward("POST", raw) def _forward(self, method, raw): - with stats.lock: - stats.running += 1 - stats.requests_total += 1 + counted = self.path.startswith("/v1/") # health checks aren't requests + if counted: + with stats.lock: + stats.running += 1 + stats.requests_total += 1 try: conn = http.client.HTTPConnection("127.0.0.1", inner_port, timeout=3600) headers = {"Content-Type": self.headers.get("Content-Type", "application/json")} @@ -150,8 +152,9 @@ def make_handler(inner_port, served_name, context, key, stats): except (BrokenPipeError, ConnectionResetError): pass finally: - with stats.lock: - stats.running -= 1 + if counted: + with stats.lock: + stats.running -= 1 def _count_event(self, event): if not event.startswith(b"data: {"):