fastmcp/tests/utilities
Jeremiah Lowin c8b8911226
Stop gather() from creating coroutines it may never schedule (#4559)
* Fix: gather() eagerly creates coroutines before scheduling them

AggregateProvider fans out Provider.get_tool() (and sibling calls) across
child providers via gather(*[p.get_tool(x) for p in providers]). The list
comprehension builds every coroutine up front, then gather()'s scheduling
loop hands them to an anyio task group one at a time. If that loop is
interrupted partway through - e.g. by pytest-timeout's SIGALRM-based
per-test timeout, which can fire between any two bytecode instructions,
unlike normal async cancellation - any coroutine not yet scheduled is
abandoned and silently garbage collected later, producing a "coroutine
'Provider.get_tool' was never awaited" warning attributed to whatever
unrelated test happens to be running when the GC gets to it.

Change gather() to take a single iterable consumed lazily, one awaitable
at a time, right before each is scheduled, and close any awaitable that
was just retrieved if scheduling it raises. Update call sites to pass
generator expressions instead of eagerly-built lists so coroutine
creation and scheduling stay tightly coupled.

* Close unscheduled awaitables from eager callers; make get_tasks lazy
2026-07-20 11:01:30 -04:00
..
json_schema_type fix: guard recursive refs in json_schema_to_type (#4312) 2026-06-24 11:53:36 -04:00
openapi Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
httpx2_mock.py Add server-side identity assertion (SEP-990 ID-JAG) (#4483) 2026-07-18 19:52:15 -04:00
test_asgi_transport.py Make the unit suite fast: in-process HTTP tests, no real sleeps, parallel Windows CI (#4554) 2026-07-20 10:51:14 -04:00
test_async_utils.py Stop gather() from creating coroutines it may never schedule (#4559) 2026-07-20 11:01:30 -04:00
test_auth.py feat: option to add upstream claims to the FastMCP proxy JWT (#2997) 2026-01-28 15:57:24 -05:00
test_cli.py Fix path resolution in install commands (#1951) 2025-09-29 20:04:12 -04:00
test_components.py Stabilize upgraded ty checks (#4526) 2026-07-17 17:46:53 -04:00
test_docstring_parsing.py Extract parameter descriptions from docstrings (#3872) 2026-04-12 13:43:48 -04:00
test_http.py Add targeted coverage tests (#4230) 2026-05-25 18:57:28 -04:00
test_inspect.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_inspect_icons.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_json_schema.py Don't mutate the caller's schema in compress_schema (#4492) 2026-07-17 17:29:01 -04:00
test_logging.py Add enable_rich_logging setting to disable rich formatting (#2893) 2026-01-16 20:29:29 -05:00
test_skills.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_tests.py Fix typos (#4498) 2026-07-18 21:18:39 -04:00
test_timeout.py Add targeted coverage tests (#4230) 2026-05-25 18:57:28 -04:00
test_token_cache.py Extract TokenCache utility, add caching to GitHubTokenVerifier (#3547) 2026-03-18 15:26:09 -04:00
test_typeadapter.py Fix method-bound tools (#1360) 2025-08-04 09:41:05 -04:00
test_types.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_version_check.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00