| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… threads Replace multiprocessing.Process with threading.Thread for the context_aware_server fixture so coverage.py can track server-side code. - Remove 5 pragma: no cover markers now reachable by coverage - Graceful shutdown via server.should_exit instead of proc.kill() - All 61 tests pass, pyright/ruff clean Part of modelcontextprotocol#1678
…_aware handler - Add pragma: no branch for ctx.request guards (always truthy in test env) - Add pragma: no cover for unknown tool fallback return (never reached in tests) - Fixes coverage failure: these branches are defensive code paths that cannot be exercised through the test fixtures
Python 3.14 deprecates asyncio.iscoroutinefunction(), which uvicorn calls internally. With pytest's filterwarnings=['error'], this DeprecationWarning becomes an exception that kills the server thread before it can start listening. In multiprocessing mode this was hidden because child processes don't inherit pytest's warning filters. Threading shares the same process, so we need to explicitly suppress DeprecationWarnings in the server thread.
On Windows Python 3.13, the ProactorBasePipeTransport.__del__ fires during GC after the threaded uvicorn server shuts down, raising a PytestUnraisableExceptionWarning due to filterwarnings=['error']. Force a GC collection with warnings suppressed so the transport finalizer runs before pytest's unraisable-exception hook can catch it.
On Windows Python 3.13, the ProactorBasePipeTransport finalizer fires during GC after the threaded uvicorn server shuts down, raising PytestUnraisableExceptionWarning. Add a filterwarnings marker to all tests that use the threaded context_aware_server fixture.
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore") | ||
| server_instance.run() |
There was a problem hiding this comment.
What is the warning here?
It does make sense to use a thread here.
Sorry, something went wrong.
| # Marker to suppress Windows ProactorEventLoop teardown warnings on threaded servers. | ||
| # When uvicorn runs in a thread (instead of a subprocess), transport finalizers fire | ||
| # during GC in the main process and trigger PytestUnraisableExceptionWarning. | ||
| _suppress_transport_teardown = pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning") |
There was a problem hiding this comment.
We can wait the shutdown... I don't think we want this.
Sorry, something went wrong.
|
Thanks for the PR. This has since landed via #2767. Closing as part of a general backlog cleanup ahead of the v2 release. If this is still relevant against current main, feel free to reopen. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Motivation
Part of #1678
The context_aware_server test fixture launches a server via multiprocessing.Process, so coverage.py cannot track its execution. This PR applies the same in-process threading approach to this fixture.
Changes