Skip to content

Commit 2eed9ce

Browse files
committed
ruff formatter fix
1 parent 465427b commit 2eed9ce

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import asyncio
2+
import time
3+
4+
5+
def fetch_sync(name: str, delay: float) -> str:
6+
time.sleep(delay)
7+
return f"{name} done"
8+
9+
async def fetch_async(name: str, delay: float) -> str:
10+
await asyncio.sleep(delay) # yields control to event loop
11+
return f"{name} done"
12+
13+
async def main():
14+
start = time.perf_counter()
15+
16+
17+
result1 = await fetch_async("A", 1)
18+
19+
result2 = fetch_sync("B", 1)
20+
# result2 = await fetch_async("B", 1)
21+
22+
result3 = await fetch_async("C", 1)
23+
24+
# print(f"{result1} | {result2} | {result3} | {result4}")
25+
print(f"{result1} | {result2} | {result3}")
26+
print("elapsed:", round(time.perf_counter() - start, 2), "seconds")
27+
28+
if __name__ == "__main__":
29+
asyncio.run(main())

tests/server/fastmcp/test_func_metadata.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,7 @@ def func_with_metadata() -> Annotated[int, Field(gt=1)]: ... # pragma: no branc
11961196

11971197
@pytest.mark.anyio
11981198
async def test_sync_tool_does_not_block_event_loop() -> None:
1199-
"""
1200-
Regression test: sync tools must not run inline on the event loop.
1199+
"""Regression test: sync tools must not run inline on the event loop.
12011200
12021201
If sync tools run inline, this test will fail because `fast_probe`
12031202
won't get scheduled until after `time.sleep`.
@@ -1245,8 +1244,7 @@ async def fast_probe() -> None:
12451244

12461245
@pytest.mark.anyio
12471246
async def test_sync_function_runs_in_worker_thread():
1248-
"""
1249-
Ensure synchronous tools are executed in a worker thread via anyio.to_thread.run_sync,
1247+
"""Ensure synchronous tools are executed in a worker thread via anyio.to_thread.run_sync,
12501248
instead of blocking the event loop thread.
12511249
"""
12521250

0 commit comments

Comments
 (0)