Title: `asyncio.start_server()` leaves the transport open when a synchronous client callback raises · Issue #155928 · python/cpython · GitHub
Open Graph Title: `asyncio.start_server()` leaves the transport open when a synchronous client callback raises · Issue #155928 · python/cpython
X Title: `asyncio.start_server()` leaves the transport open when a synchronous client callback raises · Issue #155928 · python/cpython
Description: Bug report Bug description: When a synchronous client_connected_cb passed to asyncio.start_server() raises, the exception is reported by the event loop, but the server-side transport remains open. import asyncio async def main(): loop = ...
Open Graph Description: Bug report Bug description: When a synchronous client_connected_cb passed to asyncio.start_server() raises, the exception is reported by the event loop, but the server-side transport remains open. ...
X Description: Bug report Bug description: When a synchronous client_connected_cb passed to asyncio.start_server() raises, the exception is reported by the event loop, but the server-side transport remains open. ...
Opengraph URL: https://github.com/python/cpython/issues/155928
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`asyncio.start_server()` leaves the transport open when a synchronous client callback raises","articleBody":"# Bug report\n\n### Bug description:\n\nWhen a synchronous `client_connected_cb` passed to `asyncio.start_server()` raises, the exception is reported by the event loop, but the server-side transport remains open.\n\n ```python\n import asyncio\n\n\n async def main():\n loop = asyncio.get_running_loop()\n errors = []\n loop.set_exception_handler(lambda _, ctx: errors.append(ctx))\n\n connected = loop.create_future()\n\n def callback(reader, writer):\n connected.set_result(writer.transport)\n raise RuntimeError(\"boom\")\n\n server = await asyncio.start_server(callback, \"127.0.0.1\", 0)\n _, client = await asyncio.open_connection(\n *server.sockets[0].getsockname()\n )\n\n transport = await connected\n print(len(errors), transport.is_closing()) # 1 False\n\n transport.close()\n client.close()\n server.close()\n await server.wait_closed()\n\n\n asyncio.run(main())\n ```\n\n The exception is reported once, but `transport.is_closing()` remains `False`.\n\n Coroutine callbacks already close the transport when their task fails. The synchronous path should provide the same cleanup while preserving the existing exception reporting through `Handle._run()`.\n\n Related: #110894 and PR #111601.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155937\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/yangbaechu","@type":"Person","name":"yangbaechu"},"datePublished":"2026-08-17T04:04:27Z","url":"https://github.com/python/cpython/issues/155928"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f39a2e0e-570d-f8e0-1869-7968dbb567bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9632:1087D4:37A1581:4A44328:6B021B85 |
| html-safe-nonce | decb20718bb865d861e6e0302021967bf4f4674b56bee8ac5d31aeb1800aaa06 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjMyOjEwODdENDozN0ExNTgxOjRBNDQzMjg6NkIwMjFCODUiLCJ2aXNpdG9yX2lkIjoiNTM2ODE2NTc1MjU5Nzc4MTM4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd6bcf964a2c90ecd6bea8a6def54d52007a8b7e65f03ad82adc59c01d727e6c |
| hovercard-subject-tag | issue:5168113149 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/155928/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b8db981c71083b105b11ab3b421d808e7ce9fcd8c4333ab6da694590e3c8bcde/python/cpython/issues/155928 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b8db981c71083b105b11ab3b421d808e7ce9fcd8c4333ab6da694590e3c8bcde/python/cpython/issues/155928 |
| og:image:alt | Bug report Bug description: When a synchronous client_connected_cb passed to asyncio.start_server() raises, the exception is reported by the event loop, but the server-side transport remains open. ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yangbaechu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width