Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Measure blocking duration with perf_counter in transform_fn generator test (#6014)

Lokeshrao69d720db2570bb
diff --git a/tests/tools/tool_transform/test_tool_transform.py b/tests/tools/tool_transform/test_tool_transform.py
index 55135e041..0f07b3c8d 100644
--- a/tests/tools/tool_transform/test_tool_transform.py
+++ b/tests/tools/tool_transform/test_tool_transform.py
@@ -1007,9 +1007,11 @@ async def test_transform_fn_blocking_sync_generator_does_not_stall_event_loop():
await client.call_tool("gen_blocking", {}) # warm up call machinery
heartbeat_task = asyncio.create_task(heartbeat())
try:
- started = loop.time()
+ # perf_counter, not loop.time(): on Windows the loop clock ticks
+ # every ~15.6ms and can read the full blocking duration as short.
+ started = time.perf_counter()
result = await client.call_tool("gen_blocking", {})
- elapsed = loop.time() - started
+ elapsed = time.perf_counter() - started
finally:
heartbeat_task.cancel()