René's URL Explorer Experiment


Title: gh-112202: Ensure that condition.notify() succeeds even when racing with Task.cancel() by kristjanvalur · Pull Request #112201 · python/cpython · GitHub

Open Graph Title: gh-112202: Ensure that condition.notify() succeeds even when racing with Task.cancel() by kristjanvalur · Pull Request #112201 · python/cpython

X Title: gh-112202: Ensure that condition.notify() succeeds even when racing with Task.cancel() by kristjanvalur · Pull Request #112201 · python/cpython

Description: If Condition.notify() raises an exception that could have occurred after the task was selected to be woken up, wake up another task instead, if available. This ensures that the typical case, of waking up one task to handle something, will succeed even if the candidate task is cancelled at the same time or otherwise wakes up with an error. This may result in a spurious wakeup of a waiting task, which is what the Condition Variable protocol specifies, precisely because waking up tasks conservatively (rather wake up too many than too few) is the safest and simplest to implement, and missing wakeups are serious (and cause deadlocks), while extra wakeups are easily handled by application code. IMHO trying to guarantee that we never perform any extra wakeups would complicate the code too much and be too hard to verify, particularly since that is not a guarantee that Condition Variables are supposed to provide. The PR includes Tests Fix to asyncio.Condition where raising an exception out of condition.wait after having released the lock will result in a second task being awoken, if available Documentation changes explaining the Condition Variable protocol and how if favors too many wakeups over to few wakeups (i.e. how "spurious wakeups" may occur) 📚 Documentation preview 📚: https://cpython-previews--112201.org.readthedocs.build/ Issue: gh-112202

Open Graph Description: If Condition.notify() raises an exception that could have occurred after the task was selected to be woken up, wake up another task instead, if available. This ensures that the typical case, of wa...

X Description: If Condition.notify() raises an exception that could have occurred after the task was selected to be woken up, wake up another task instead, if available. This ensures that the typical case, of wa...

Opengraph URL: https://github.com/python/cpython/pull/112201

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:bfe4e86f-1781-ee80-35c8-6e0c8b503655
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD124:32AC14:5BFF866:78A004F:6A5DB339
html-safe-nonce97c83dd10909dd6c1ce1930d4df8712eb36ae897016e735da2842596fa78208d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTI0OjMyQUMxNDo1QkZGODY2Ojc4QTAwNEY6NkE1REIzMzkiLCJ2aXNpdG9yX2lkIjoiNjY3NTMxMzA5NDYzNzIzNzA0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca1c0b4f4378c481dbb46b47df2951c13f17cf408c5f7355a07b4f64a7971e480
hovercard-subject-tagpull_request:1606473776
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/112201/files
twitter:imagehttps://avatars.githubusercontent.com/u/6009543?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/6009543?s=400&v=4
og:image:altIf Condition.notify() raises an exception that could have occurred after the task was selected to be woken up, wake up another task instead, if available. This ensures that the typical case, of wa...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/112201/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F112201%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F112201%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/112201/files
Reloadhttps://github.com/python/cpython/pull/112201/files
Reloadhttps://github.com/python/cpython/pull/112201/files
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.4k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
gvanrossumhttps://github.com/gvanrossum
python:mainhttps://github.com/python/cpython/tree/main
kristjanvalur:kristjan/condition_notifyhttps://github.com/kristjanvalur/stackless/tree/kristjan/condition_notify
Conversation 33 https://github.com/python/cpython/pull/112201
Commits 8 https://github.com/python/cpython/pull/112201/commits
Checks 0 https://github.com/python/cpython/pull/112201/checks
Files changed https://github.com/python/cpython/pull/112201/files
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
gh-112202: Ensure that condition.notify() succeeds even when racing with Task.cancel() https://github.com/python/cpython/pull/112201/files#top
Show all changes 8 commits https://github.com/python/cpython/pull/112201/files
fa8d5e4 Handle race between task.cancel() and contidion.notify() kristjanvalur Nov 17, 2023 https://github.com/python/cpython/pull/112201/commits/fa8d5e40877ce17a4bc23c979dd96abc9aa60ff6
df113e5 Improve test, add another test case kristjanvalur Nov 18, 2023 https://github.com/python/cpython/pull/112201/commits/df113e5765356953e0554cacf32706299a72b69e
13827d1 📜🤖 Added by blurb_it. blurb-it[bot] Jan 12, 2024 https://github.com/python/cpython/pull/112201/commits/13827d15d1c5bb6ab16e426fb5f1202b9b939ba7
c8e6b13 Update Doc/library/asyncio-sync.rst kristjanvalur Jan 12, 2024 https://github.com/python/cpython/pull/112201/commits/c8e6b13f490e3efa9c1a1e21b7f878a9032c3f6f
db3f83a Apply suggestions from code review kristjanvalur Jan 16, 2024 https://github.com/python/cpython/pull/112201/commits/db3f83ae5d29f666d9da14b5de4f84a87a363afe
0dad880 Change mention of "coroutines" to "tasks" where appopriate in in-line… kristjanvalur Jan 16, 2024 https://github.com/python/cpython/pull/112201/commits/0dad8803b4d43e6a85ece682351afb59ecb56b17
12bb758 awoken/awakened kristjanvalur Jan 16, 2024 https://github.com/python/cpython/pull/112201/commits/12bb7585483917191fe32ab130adf32b0bca8066
92566a1 Apply suggestions from code review kristjanvalur Feb 3, 2024 https://github.com/python/cpython/pull/112201/commits/92566a139137b651b93b13aefacd29bd9c81c43a
Clear filters https://github.com/python/cpython/pull/112201/files
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
asyncio-sync.rst https://github.com/python/cpython/pull/112201/files#diff-da9e04da89bf27b724908a4e932748e29d451ecbefef1b570c466d16d813181f
locks.py https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
test_locks.py https://github.com/python/cpython/pull/112201/files#diff-49a2abccf92f646db3568727885f472bd096941b187c3580d56d96484fc74193
2024-01-12-09-35-07.gh-issue-112202.t_0V1m.rst https://github.com/python/cpython/pull/112201/files#diff-19adfc60df380541a67025736620dc9ba7a8e130f9326e6f7a2a12670ac4e587
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L377
Doc/library/asyncio-sync.rsthttps://github.com/python/cpython/pull/112201/files#diff-da9e04da89bf27b724908a4e932748e29d451ecbefef1b570c466d16d813181f
View file https://github.com/kristjanvalur/stackless/blob/92566a139137b651b93b13aefacd29bd9c81c43a/Doc/library/asyncio-sync.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/112201/{{ revealButtonHref }}
https://github.com/python/cpython/pull/112201/files#diff-da9e04da89bf27b724908a4e932748e29d451ecbefef1b570c466d16d813181f
https://github.com/python/cpython/pull/112201/files#diff-da9e04da89bf27b724908a4e932748e29d451ecbefef1b570c466d16d813181f
https://github.com/python/cpython/pull/112201/files#diff-da9e04da89bf27b724908a4e932748e29d451ecbefef1b570c466d16d813181f
https://github.com/python/cpython/pull/112201/files#diff-da9e04da89bf27b724908a4e932748e29d451ecbefef1b570c466d16d813181f
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L379
Lib/asyncio/locks.pyhttps://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
View file https://github.com/kristjanvalur/stackless/blob/92566a139137b651b93b13aefacd29bd9c81c43a/Lib/asyncio/locks.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/112201/{{ revealButtonHref }}
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
gvanrossumhttps://github.com/gvanrossum
Nov 18, 2023https://github.com/python/cpython/pull/112201/files#r1398283714
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
kristjanvalurhttps://github.com/kristjanvalur
Jan 12, 2024https://github.com/python/cpython/pull/112201/files#r1450153978
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
gvanrossumhttps://github.com/gvanrossum
Jan 14, 2024https://github.com/python/cpython/pull/112201/files#r1451812714
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
kristjanvalurhttps://github.com/kristjanvalur
Jan 16, 2024https://github.com/python/cpython/pull/112201/files#r1453888408
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/112201/files
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/pull/112201/files#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L380
Lib/test/test_asyncio/test_locks.pyhttps://github.com/python/cpython/pull/112201/files#diff-49a2abccf92f646db3568727885f472bd096941b187c3580d56d96484fc74193
View file https://github.com/kristjanvalur/stackless/blob/92566a139137b651b93b13aefacd29bd9c81c43a/Lib/test/test_asyncio/test_locks.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/112201/{{ revealButtonHref }}
https://github.com/python/cpython/pull/112201/files#diff-49a2abccf92f646db3568727885f472bd096941b187c3580d56d96484fc74193
https://github.com/python/cpython/pull/112201/files#diff-49a2abccf92f646db3568727885f472bd096941b187c3580d56d96484fc74193
Misc/NEWS.d/next/Library/2024-01-12-09-35-07.gh-issue-112202.t_0V1m.rsthttps://github.com/python/cpython/pull/112201/files#diff-19adfc60df380541a67025736620dc9ba7a8e130f9326e6f7a2a12670ac4e587
View file https://github.com/kristjanvalur/stackless/blob/92566a139137b651b93b13aefacd29bd9c81c43a/Misc/NEWS.d/next/Library/2024-01-12-09-35-07.gh-issue-112202.t_0V1m.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/112201/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.