Title: Calling SelectorSocketTransport.writelines with a very large payload doesn't get completely written to the socket · Issue #103462 · python/cpython · GitHub
Open Graph Title: Calling SelectorSocketTransport.writelines with a very large payload doesn't get completely written to the socket · Issue #103462 · python/cpython
X Title: Calling SelectorSocketTransport.writelines with a very large payload doesn't get completely written to the socket · Issue #103462 · python/cpython
Description: Bug report As a consequence of the optimization introduced in #91166, when SelectorSocketTransport.writelines is used with a very large buffer which can't be written in one shot either by using socket.send or socket.sendmsg the remaining...
Open Graph Description: Bug report As a consequence of the optimization introduced in #91166, when SelectorSocketTransport.writelines is used with a very large buffer which can't be written in one shot either by using soc...
X Description: Bug report As a consequence of the optimization introduced in #91166, when SelectorSocketTransport.writelines is used with a very large buffer which can't be written in one shot either by using...
Opengraph URL: https://github.com/python/cpython/issues/103462
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Calling SelectorSocketTransport.writelines with a very large payload doesn't get completely written to the socket","articleBody":"# Bug report\r\n\r\nAs a consequence of the optimization introduced in #91166, when `SelectorSocketTransport.writelines` is used with a very large buffer which can't be written in one shot either by using `socket.send` or `socket.sendmsg` the remaining data in the buffer is never written to the socket. \r\n\r\nThe following example can be used to reproduce the error:\r\n\r\n```python\r\nimport asyncio\r\n\r\n\r\nasync def send_message(chunk_size: int, chunks: int):\r\n await asyncio.sleep(1)\r\n reader, writer = await asyncio.open_connection(\"127.0.0.1\", 9898)\r\n data = [bytes(chunk_size)] * chunks + [b\"end\"]\r\n writer.writelines(data)\r\n await writer.drain()\r\n writer.close()\r\n await writer.wait_closed()\r\n\r\n\r\nasync def handle_message(reader, writer):\r\n data = await reader.read()\r\n print(f\"End marker: {data[-3:]!r}\")\r\n writer.close()\r\n await writer.wait_closed()\r\n\r\n\r\nasync def run_server():\r\n server = await asyncio.start_server(handle_message, \"127.0.0.1\", 9898)\r\n async with server:\r\n await server.serve_forever()\r\n\r\n\r\nasync def main():\r\n await asyncio.gather(run_server(), send_message(6500, 100))\r\n\r\n\r\nasyncio.run(main())\r\n```\r\n\r\nThe example above prints `End marker: b'end'` with python 3.11 but not with python `3.12.0a6+`\r\n\r\n# Your environment\r\n\r\n- CPython versions tested on: `3.12.0a7`\r\n- Operating system and architecture: macOS 13.2\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103463\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/alisaifee","@type":"Person","name":"alisaifee"},"datePublished":"2023-04-12T02:00:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/103462/cpython/issues/103462"}
| 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:6d9a9fb7-2bf4-e18a-cfa5-0911e35728d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD7C:84B9D:6EFDD9:9AEF68:696A28DD |
| html-safe-nonce | c4010643f3bf8c47b86204034773841961d50277cf3ff43d33aa61728aa7f6b0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDdDOjg0QjlEOjZFRkREOTo5QUVGNjg6Njk2QTI4REQiLCJ2aXNpdG9yX2lkIjoiNTk5NDg1ODU2MTE3MjgwOTk0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9b75624470c05f56313999e8f275bc9f28d388d3c579aa5cc362c0141c29bb02 |
| hovercard-subject-tag | issue:1663541332 |
| 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/103462/issue_layout |
| twitter:image | https://opengraph.githubassets.com/badd8c6b99760aabfb3a16ab9a1862def2f82aa9e1fd4b7cbeec12aef2f1e3b6/python/cpython/issues/103462 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/badd8c6b99760aabfb3a16ab9a1862def2f82aa9e1fd4b7cbeec12aef2f1e3b6/python/cpython/issues/103462 |
| og:image:alt | Bug report As a consequence of the optimization introduced in #91166, when SelectorSocketTransport.writelines is used with a very large buffer which can't be written in one shot either by using soc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alisaifee |
| hostname | github.com |
| expected-hostname | github.com |
| None | a1022f03e4f0d91ea173e4e5dac892c982e0588c62f1ce56121d755a320a3569 |
| 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 | f472b8e6c7b3fdd5d0354972a3f4c516289bf0be |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width