Skip to content

fix: terminate active streamable http sessions on shutdown#2362

Closed
raashish1601 wants to merge 1 commit into
modelcontextprotocol:mainfrom
raashish1601:contributor-12/python-sdk-2150
Closed

fix: terminate active streamable http sessions on shutdown#2362
raashish1601 wants to merge 1 commit into
modelcontextprotocol:mainfrom
raashish1601:contributor-12/python-sdk-2150

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • terminate active stateful streamable HTTP transports before cancelling the session-manager task group during shutdown
  • keep the manager's session registry consistent while transports are being closed
  • add a regression that keeps one stateful session alive and verifies shutdown awaits transport termination

Fixes #2150.

Testing

  • python -m pytest tests/server/test_streamable_http_manager.py -k 'test_run_terminates_active_stateful_sessions_on_shutdown or test_stateful_session_cleanup_on_graceful_exit'
  • python -m ruff check src/mcp/server/streamable_http_manager.py tests/server/test_streamable_http_manager.py

@maxisbey
Copy link
Copy Markdown
Contributor

Closing in favor of #2253, which also closes _sse_stream_writers in terminate() (the second half of the root cause analysis on #2150). Your regression test is worth carrying over. Thanks for the contribution.

AI Disclaimer

@maxisbey maxisbey closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Active Streamable HTTP sessions are not terminated during shutdown

2 participants