Title: bpo-30064: Fix asyncio loop.sock_* race condition issue by fantix · Pull Request #20369 · python/cpython · GitHub
Open Graph Title: bpo-30064: Fix asyncio loop.sock_* race condition issue by fantix · Pull Request #20369 · python/cpython
X Title: bpo-30064: Fix asyncio loop.sock_* race condition issue by fantix · Pull Request #20369 · python/cpython
Description: https://bugs.python.org/issue30064 This is reproducible by a cancel() followed directly by a retry: done, pending = await asyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) if done: data = await done.pop() else: pending.pop().cancel() data = await loop.sock_recv(sock, 1024) This issue applies to all the loop.sock_* methods. Without this PR, users could work it around by adding a sleep(0): done, pending = await asyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) if done: data = await done.pop() else: pending.pop().cancel() await asyncio.sleep(0) # <---- this ensures that the right reader is removed data = await loop.sock_recv(sock, 1024)
Open Graph Description: https://bugs.python.org/issue30064 This is reproducible by a cancel() followed directly by a retry: done, pending = await asyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) if done: data ...
X Description: https://bugs.python.org/issue30064 This is reproducible by a cancel() followed directly by a retry: done, pending = await asyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) if done: data ...
Opengraph URL: https://github.com/python/cpython/pull/20369
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:67b01060-bbb0-23f9-e38e-9cf99d51c6f7 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BDC6:14C034:E67786:13C8964:6969F393 |
| html-safe-nonce | 3a85475a803f90c64ea9d68938b608c2bae1f8043a6995d2c853b5713c288bd1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREM2OjE0QzAzNDpFNjc3ODY6MTNDODk2NDo2OTY5RjM5MyIsInZpc2l0b3JfaWQiOiIzNDY5OTY3MjAzMzQxMzAwNjI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 70624a281325765ffd12548600125c3258cb3a78f55da2ade693221afb2c97d7 |
| hovercard-subject-tag | pull_request:422482704 |
| 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/python/cpython/pull/20369/files |
| twitter:image | https://avatars.githubusercontent.com/u/1751601?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1751601?s=400&v=4 |
| og:image:alt | https://bugs.python.org/issue30064 This is reproducible by a cancel() followed directly by a retry: done, pending = await asyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) if done: data ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width