◐ Shell
clean mode source ↗

Deflake the issue-1363 tests: wait for lifespan startup instead of sleeping by maxisbey · Pull Request #2879 · modelcontextprotocol/python-sdk

…eeping

The three tests in test_1363_race_condition_streamable_http.py waited a
fixed 0.1s for the ServerThread to start the app lifespan before sending
requests. On a loaded CI runner the thread is sometimes not ready in time,
so the first request reaches handle_request() before the session manager's
task group exists and the test fails with "RuntimeError: Task group is not
initialized" (seen intermittently on both Ubuntu and Windows jobs).

Replace the fixed sleep with a threading.Event that the server thread sets
once lifespan startup has completed; the tests wait for it (bounded at 5s)
before sending the first request.

@maxisbey marked this pull request as ready for review

June 15, 2026 15:48

felixweinberger

@maxisbey maxisbey deleted the maxisbey/deflake-1363-startup-handshake branch

June 15, 2026 15:51