Title: bpo-32751: Wait for task cancellation in asyncio.wait_for() by elprans · Pull Request #7216 · python/cpython · GitHub
Open Graph Title: bpo-32751: Wait for task cancellation in asyncio.wait_for() by elprans · Pull Request #7216 · python/cpython
X Title: bpo-32751: Wait for task cancellation in asyncio.wait_for() by elprans · Pull Request #7216 · python/cpython
Description: Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic when fut is a Task, because it will be left running for an arbitrary amount of time. This behavior is iself surprising and may lead to related bugs such as the one described in bpo-33638: condition = asyncio.Condition() async with condition: await asyncio.wait_for(condition.wait(), timeout=0.5) Currently, instead of raising a TimeoutError, the above code will fail with RuntimeError: cannot wait on un-acquired lock, because __aexit__ is reached before condition.wait() finishes its cancellation and re-acquires the condition lock. To resolve this, make wait_for await for the task cancellation. The tradeoff here is that the timeout promise may be broken if the task decides to handle its cancellation in a slow way. This represents a behavior change and should probably not be back-patched to 3.6 and earlier. https://bugs.python.org/issue32751
Open Graph Description: Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic when fut is a Task, because it will be left running for an arb...
X Description: Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic when fut is a Task, because it will be left running for an arb...
Opengraph URL: https://github.com/python/cpython/pull/7216
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:43f18047-ae8e-120f-7e18-af2acc381005 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AD90:1B5BC7:4E9DB0:716DA8:6A59E2B8 |
| html-safe-nonce | 586ee92282b8af90449ac2e578e0ae90d26d64a5cf28b2971c3a0e778a3e66b7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDkwOjFCNUJDNzo0RTlEQjA6NzE2REE4OjZBNTlFMkI4IiwidmlzaXRvcl9pZCI6IjMwNDQyNDkzMDE5NDgxNjI3NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d29c18aa38f20018d8987b37a654019988853bca978e3d44bf0941052c498024 |
| hovercard-subject-tag | pull_request:191249587 |
| 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/7216/files |
| twitter:image | https://avatars.githubusercontent.com/u/347119?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/347119?s=400&v=4 |
| og:image:alt | Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic when fut is a Task, because it will be left running for an arb... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353 |
| 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 | 26f17126414f953984d8ae42f57c0db48e7dbde3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width