Use anyio as testing backend to radically simplify remote MCP testing #2006
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request migrates the test infrastructure from
asyncio
toanyio
, modernizing the async concurrency model and improving test speed, determinism, and reliability.Presently, many tests (including almost all for remote MCP transports) run in subprocesses. This is time-consuming, resource-intensive, and makes debugging extremely difficult when errors surface in the subprocess instead of in the client.
This PR refactors all subprocess tests to instead run in anyio task groups, which has dramatic performance benefits (cutting local test time roughly in half) as well as resulting in sane tracebacks and debugging on the servers. Generally speaking,
run_server_async
replacesrun_server_in_process
in the test suite.Apart from adjusting
asyncio.Lock
toanyio.Lock
, this PR is almost entirely confined to the test suite.