Title: [3.7] bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216) by miss-islington · Pull Request #7223 · python/cpython · GitHub
Open Graph Title: [3.7] bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216) by miss-islington · Pull Request #7223 · python/cpython
X Title: [3.7] bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216) by miss-islington · Pull Request #7223 · python/cpython
Description: Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic for 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. (cherry picked from commit e2b340a) Co-authored-by: Elvis Pranskevichus elvis@magic.io 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 for when fut is a Task, because it will be left running for an...
X Description: Currently, asyncio.wait_for(fut), upon reaching the timeout deadline, cancels the future and returns immediately. This is problematic for when fut is a Task, because it will be left running for an...
Opengraph URL: https://github.com/python/cpython/pull/7223
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:25ce99b2-f151-9748-fd76-6e2405f661d0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E940:14D93F:35923:47FC9:6A5A645B |
| html-safe-nonce | 907a7faa0dafa6b5a0074d6d66a0152b91bf22d16d03344b25deb3dc9ae0b306 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTQwOjE0RDkzRjozNTkyMzo0N0ZDOTo2QTVBNjQ1QiIsInZpc2l0b3JfaWQiOiIzODI4MDY4MzYwODgzMTY4MzQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 121702a3074b07fc4be2622983cf4387e245070c3c47883c127184f83c1f8673 |
| hovercard-subject-tag | pull_request:191276092 |
| 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/7223/files |
| twitter:image | https://avatars.githubusercontent.com/u/31488909?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/31488909?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 for when fut is a Task, because it will be left running for an... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 05b9ddf6a47d2dbe13944873a99f5fb4b83ba4871f9cb8a8e256793a63ca9687 |
| 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 | f8d29d1bd03dda2dd14b3f80b8bc27e1111f43bd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width