-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Streamable Http - clean up server memory streams #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, couple minor its inline but your call whether they're worth the time
src/mcp/server/streamable_http.py
Outdated
await write_stream.aclose() | ||
except Exception as e: | ||
logger.debug(f"Error closing streams: {e}") | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant?
await self._request_streams[request_id][0].aclose() | ||
await self._request_streams[request_id][1].aclose() | ||
except Exception as e: | ||
logger.debug(f"Error closing memory streams: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exceptions would we expect to see here? I'm slightly worried about swallowing everything, since (I think) aclose()
itself shouldn't normally throw anything
await self._write_stream_reader.aclose() | ||
if self._write_stream is not None: | ||
await self._write_stream.aclose() | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same q about possibly narrowing down the exceptions we really want to suppress here (maybe all? but just flagging)
…essage-for-related-request
…pr/client-resumability
…essage-for-related-request
…pr/client-resumability
Saving only one read stream in
_request_streams
is not right as we need to clean up both - read and write streams.