From e63855ccf3807a16bdd5aee3c73a3cfefd8eda70 Mon Sep 17 00:00:00 2001 From: Chris Guidry Date: Fri, 5 Dec 2025 12:36:20 -0500 Subject: [PATCH] fix: use simple sleep for server readiness, restore Windows parallelism --- .github/workflows/run-tests.yml | 8 +------- src/fastmcp/utilities/tests.py | 11 ++--------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f4a7c847a..a3fb99999 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -48,13 +48,7 @@ jobs: run: uv sync --upgrade - name: Run tests (excluding integration and client_process) - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - # Run without parallelism on Windows to debug xdist crashes - uv run pytest --inline-snapshot=disable tests -m "not integration and not client_process" - else - uv run pytest --inline-snapshot=disable tests -m "not integration and not client_process" --numprocesses auto --maxprocesses 4 --dist worksteal - fi + run: uv run pytest --inline-snapshot=disable tests -m "not integration and not client_process" --numprocesses auto --maxprocesses 4 --dist worksteal shell: bash - name: Run client process tests separately diff --git a/src/fastmcp/utilities/tests.py b/src/fastmcp/utilities/tests.py index e5f9cac71..d78ce3e62 100644 --- a/src/fastmcp/utilities/tests.py +++ b/src/fastmcp/utilities/tests.py @@ -212,15 +212,8 @@ async def run_server_async( # Wait for server lifespan to be ready await server._started.wait() - # Wait for HTTP server to be ready by making a request - url = f"http://{host}:{port}{path}" - async with httpx.AsyncClient() as client: - for _ in range(50): # 50 * 0.1s = 5s timeout - try: - await client.get(url, timeout=0.1) - break - except (httpx.ConnectError, httpx.TimeoutException): - await asyncio.sleep(0.1) + # Give uvicorn a moment to bind the port after lifespan is ready + await asyncio.sleep(0.1) try: yield f"http://{host}:{port}{path}"