From 17f4414be97d0ead68bf0e1d979ceefb53b072bb Mon Sep 17 00:00:00 2001 From: Ben Browning Date: Mon, 2 Jun 2025 11:24:12 -0400 Subject: [PATCH] fix: remote-vllm event loop blocking unit test on Mac (#2332) # What does this PR do? The remote-vllm `test_chat_completion_doesnt_block_event_loop` unit test was often failing for me on a Mac with a `httpx.ReadError`. I traced this back to the swap to the `AsyncOpenAI` client in the remote-vllm provider as where this started, and it looks like the async client needs a bit more accurate HTTP request handling from our mock server. So, this fixes that unit test to send proper Content-Type and Content-Length headers which makes the `AsyncOpenAI` client happier on Macs. ## Test Plan All the test_remote_vllm.py unit tests consistently pass for me on a Mac now, without any flaking in the event loop one. `pytest -s -v tests/unit/providers/inference/test_remote_vllm.py` Signed-off-by: Ben Browning --- tests/unit/providers/inference/test_remote_vllm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/providers/inference/test_remote_vllm.py b/tests/unit/providers/inference/test_remote_vllm.py index f9eaee7d6..17c867af1 100644 --- a/tests/unit/providers/inference/test_remote_vllm.py +++ b/tests/unit/providers/inference/test_remote_vllm.py @@ -69,9 +69,12 @@ class MockInferenceAdapterWithSleep: # ruff: noqa: N802 def do_POST(self): time.sleep(sleep_time) + response_body = json.dumps(response).encode("utf-8") self.send_response(code=200) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", len(response_body)) self.end_headers() - self.wfile.write(json.dumps(response).encode("utf-8")) + self.wfile.write(response_body) self.request_handler = DelayedRequestHandler