Title: Fix: memory leak and exit problems by PWZER · Pull Request #586 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Fix: memory leak and exit problems by PWZER · Pull Request #586 · modelcontextprotocol/python-sdk
X Title: Fix: memory leak and exit problems by PWZER · Pull Request #586 · modelcontextprotocol/python-sdk
Description: Motivation and Context Here handle_sse calls app.run() every time it processes a sse request, but app.run() keeps running and does not stop automatically, which causes handle_sse to never end, and finally causes a memory leak. python-sdk/examples/servers/simple-tool/mcp_simple_tool/server.py Lines 67 to 73 in b4c7db6 async def handle_sse(request): async with sse.connect_sse( request.scope, request.receive, request._send ) as streams: await app.run( streams[0], streams[1], app.create_initialization_options() ) And this is also the key reason for the following exit problems issues#541, Fixed. INFO: Waiting for background tasks to complete. (CTRL+C to force quit) Types of changes Bug fix (non-breaking change which fixes an issue) Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed
Open Graph Description: Motivation and Context Here handle_sse calls app.run() every time it processes a sse request, but app.run() keeps running and does not stop automatically, which causes handle_sse to never end, an...
X Description: Motivation and Context Here handle_sse calls app.run() every time it processes a sse request, but app.run() keeps running and does not stop automatically, which causes handle_sse to never end, an...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/586
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:442a0360-d45f-a4b8-7d24-0f858455a347 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E52A:391B0E:1C87DA6:27C2879:6A5F3E42 |
| html-safe-nonce | f1c1bbf284ca2b45bb8f7dedd561d7fef0cf6420ddffcbbb5fe033ffc61f05de |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTJBOjM5MUIwRToxQzg3REE2OjI3QzI4Nzk6NkE1RjNFNDIiLCJ2aXNpdG9yX2lkIjoiNTQxNTc2ODA1MTk0OTcxNTAxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 362097d6f3e2a9f5ea99f0779fb42ce69986fc98a68293f959dce6d9968f4d66 |
| hovercard-subject-tag | pull_request:2480499504 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/586/files |
| twitter:image | https://avatars.githubusercontent.com/u/13550831?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13550831?s=400&v=4 |
| og:image:alt | Motivation and Context Here handle_sse calls app.run() every time it processes a sse request, but app.run() keeps running and does not stop automatically, which causes handle_sse to never end, an... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ab2497d9345a59709926b385d88458fa5932c82ec066288448eb68b34cbcbbda |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ba0ac57287507693938b0a2de45402a22cda0785 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width