René's URL Explorer Experiment


Title: bpo-46752: Introduce task groups in asyncio by gvanrossum · Pull Request #31270 · python/cpython · GitHub

Open Graph Title: bpo-46752: Introduce task groups in asyncio by gvanrossum · Pull Request #31270 · python/cpython

X Title: bpo-46752: Introduce task groups in asyncio by gvanrossum · Pull Request #31270 · python/cpython

Description: This is EdgeDB's TaskGroup class, adapted for Python 3.11. In the individual commits you can see how I evolved this from the version in EdgeDB. Here's a to-do list: Figure out why in test_taskgroup_14 I get a nested ExceptionGroup, while the original got a flat MultiError. Fix the test framework's complaint about the event loop policy being changed. Design question: Do we need TaskGroupError? Implementing it correctly is awkward. We could just raise BaseExceptionGroup. If we decide to keep it, we need to fix it to do the hack where it inherits from BaseException iff at least one of the exceptions does. We also need to override derive(). Add tests for handling BaseException, KeyboardInterrupt and SystemExit. Make test_taskgroup_21 work? (It wasn't working in EdgeDB either, so it was crudely disabled.) Add a public API to tasks.py to replace __cancel_requested__, and get rid of the monkey-patching. Design question: Should we allow creating new tasks while __aexit__() is already waiting? Add a test showing the need for the .uncancel() call in __aexit__() (currently on line 97). Dropping that line does not cause any tests to fail. Ensure the taskgroup tests are run with the C and Python Task implementations. Rename tests to have meaningful names. I have a few ideas for minor cleanups that I will do later. What should we do with the copyright header? @1st1. Create a bpo issue. Add a NEWS blurb. Documentation and What's New entry (in a separate PR, probably). I also learned a few things about the ergonomics of ExceptionGroup: The BaseException hacks are clever but awkward to replicate in a subclass. The str() of an EG is rather sparse (Yury's version adds the number of sub-exceptions and their types). Yury's version also has a convenience method that returns the set of sub-exception types. Unsure about the nesting issue (see above). CC: @iritkatriel, @1st1 Co-authored-by: Yury Selivanov yury@edgedb.com Co-authored-by: Andrew Svetlov andrew.svetlov@gmail.com https://bugs.python.org/issue46752

Open Graph Description: This is EdgeDB's TaskGroup class, adapted for Python 3.11. In the individual commits you can see how I evolved this from the version in EdgeDB. Here's a to-do list: Figure out why in test...

X Description: This is EdgeDB's TaskGroup class, adapted for Python 3.11. In the individual commits you can see how I evolved this from the version in EdgeDB. Here's a to-do list: Figure out why...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3dab53c1-8443-62f4-ac69-74cbb18cd17c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id811E:277FD5:21520DE:2C9E81F:6A5BD036
html-safe-noncebe52b011dc995865dd230aa0b8a623d306d602e11e54c8024b50a4422db97847
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTFFOjI3N0ZENToyMTUyMERFOjJDOUU4MUY6NkE1QkQwMzYiLCJ2aXNpdG9yX2lkIjoiNTk2MDU4MDgwOTQ1MTM2MDMxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb00cc41e47aea1dfc9318245e4cba8fd3f716d06d005d8aabd70af3c583be323
hovercard-subject-tagpull_request:846617192
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/31270/files
twitter:imagehttps://avatars.githubusercontent.com/u/2894642?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/2894642?s=400&v=4
og:image:altThis is EdgeDB's TaskGroup class, adapted for Python 3.11. In the individual commits you can see how I evolved this from the version in EdgeDB. Here's a to-do list: Figure out why in test...
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/31270/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F31270%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%2F31270%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/31270/files
Reloadhttps://github.com/python/cpython/pull/31270/files
Reloadhttps://github.com/python/cpython/pull/31270/files
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.9k 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
gvanrossum:taskgroupshttps://github.com/gvanrossum/cpython/tree/taskgroups
Conversation 72 https://github.com/python/cpython/pull/31270
Commits 24 https://github.com/python/cpython/pull/31270/commits
Checks 0 https://github.com/python/cpython/pull/31270/checks
Files changed https://github.com/python/cpython/pull/31270/files
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
bpo-46752: Introduce task groups in asyncio https://github.com/python/cpython/pull/31270/files#top
Show all changes 24 commits https://github.com/python/cpython/pull/31270/files
7edee0b Integrate task groups from EdgeDb gvanrossum Feb 10, 2022 https://github.com/python/cpython/pull/31270/commits/7edee0b2ae2bc8fcddf677961f279b59d4bf720d
f495375 Make test_taskgroups.py run and pass gvanrossum Feb 10, 2022 https://github.com/python/cpython/pull/31270/commits/f4953754aa507b92c4dfdf1306d57ceee25365ae
a87275a Rename taskgroup to taskgroups in the test code gvanrossum Feb 10, 2022 https://github.com/python/cpython/pull/31270/commits/a87275a694fd4e40077472b7df92070584ea4e94
4df0acc Export TaskGroup from asyncio; remove __future__ import gvanrossum Feb 10, 2022 https://github.com/python/cpython/pull/31270/commits/4df0accad4163881765d25bc454d24540de8e3cd
56db921 Only keep the newest _is_base_error() and _task_cancel() gvanrossum Feb 10, 2022 https://github.com/python/cpython/pull/31270/commits/56db921d7278672cba9a6e4aac9b61a690a75fb9
500581e Get rid of MultiError in favor of ExceptionGroup gvanrossum Feb 11, 2022 https://github.com/python/cpython/pull/31270/commits/500581eb0c788043756ff1127160e8c5827cb1d2
4843e94 Add TaskGroupError to __all__ gvanrossum Feb 11, 2022 https://github.com/python/cpython/pull/31270/commits/4843e94dfc00350de44e0612e704a63dcd162c97
63e712d Avoid DeprecationWarning: There is no current event loop gvanrossum Feb 11, 2022 https://github.com/python/cpython/pull/31270/commits/63e712dc2d381f9b91cb5fe2644b17823671952a
d233dd1 Prevent warning "test altered the execution environment" gvanrossum Feb 11, 2022 https://github.com/python/cpython/pull/31270/commits/d233dd199ecfeb36fcd230589b4f435da820d9b2
af574d5 Get rid of custom TaskGroupError gvanrossum Feb 11, 2022 https://github.com/python/cpython/pull/31270/commits/af574d58300b8920127cca23d8f1878f5d614b3b
299f366 Update comments explaining why test 21 doesn't work gvanrossum Feb 12, 2022 https://github.com/python/cpython/pull/31270/commits/299f3663dcd0c0e5174d3f29e8a03681335b40d6
9de3c87 Add tests showing that 'plain' BaseExceptions work gvanrossum Feb 12, 2022 https://github.com/python/cpython/pull/31270/commits/9de3c878d1cba85bb5a21d93a22d2bbc50e12c2a
0e1355d Allow creating new tasks while __aexit__ is waiting gvanrossum Feb 12, 2022 https://github.com/python/cpython/pull/31270/commits/0e1355d55509d083ec911995ef2d7837ff888017
77ec0e4 Add an API to Task to manage 'cancel_requested' flag gvanrossum Feb 14, 2022 https://github.com/python/cpython/pull/31270/commits/77ec0e42b3fcd8a928ab89651707d6384971add7
17b64b5 Add tests for .cancelling() and .uncancel() gvanrossum Feb 14, 2022 https://github.com/python/cpython/pull/31270/commits/17b64b54ad9dd929c2ae9250a05354d0c289e949
5e3f4b9 Merge remote-tracking branch 'origin/main' into taskgroups gvanrossum Feb 14, 2022 https://github.com/python/cpython/pull/31270/commits/5e3f4b952eb2dd0139dae19e8858d5cc1397c20e
0b9bccd 📜🤖 Added by blurb_it. blurb-it[bot] Feb 14, 2022 https://github.com/python/cpython/pull/31270/commits/0b9bccd71d9b3dc0e05850e7792fa42933696b11
137ebe6 Replace EdgeDb copyright with a simpler attribution gvanrossum Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/137ebe6de92a3c7995c434e01f0fe501ed441123
f693c1c Use task.cancelling() in task repr instead of access to private attri… asvetlov Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/f693c1c989ad732aed0e742a6171c8ef2448068b
b83734c Change the internal imports gvanrossum Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/b83734cf1efec6cce890c3f3ae65892e1612bb36
de3d820 Avoid needing self.loop in test gvanrossum Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/de3d82012d3d97bed8ea50e7081404eb51ae8923
9712241 Make test 14 more robust gvanrossum Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/9712241fed0c203fc6a1612a0040b68fb7779481
b3d4d18 Update Lib/asyncio/taskgroups.py Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/b3d4d18f04780a88193257d3f62f7f9e284d91a4
c1e5d64 Update Lib/test/test_asyncio/test_taskgroups.py Feb 15, 2022 https://github.com/python/cpython/pull/31270/commits/c1e5d64a27325f3c08668aa5d255038b991bd30e
Clear filters https://github.com/python/cpython/pull/31270/files
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
__init__.py https://github.com/python/cpython/pull/31270/files#diff-6d8c6a7b5cda5773cc40309dcfeeeb120b25857274a13aba8f3c803d25397fdf
base_tasks.py https://github.com/python/cpython/pull/31270/files#diff-5eae152b5b94ab82986b91e37d76b9fbb194e533a613131166e292b16774d593
taskgroups.py https://github.com/python/cpython/pull/31270/files#diff-b90f92a0a4d63d1c6e9e82f28f7281db5fd468c356db4309e87c06a65f5606dc
tasks.py https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
test_taskgroups.py https://github.com/python/cpython/pull/31270/files#diff-6f3f42fe6cdf1387de256a705e9f0d4c809ba04a2da04c317c9c79cfc4c5bc69
test_tasks.py https://github.com/python/cpython/pull/31270/files#diff-ef1c83c981ac721906ba3b05e123351be23dcfb59e92d0aeb6f4033db9cdd8c8
2022-02-14-21-21-49.bpo-46752.m6ldTm.rst https://github.com/python/cpython/pull/31270/files#diff-14f0d433a1f3aaa4c0cb06b900656f4729c16f74681e812cf12f7baea3839484
_asynciomodule.c https://github.com/python/cpython/pull/31270/files#diff-6bd9e39980b88a721d902bcd915bbb3f24762f7f253430c45e52c42a2c5afd01
_asynciomodule.c.h https://github.com/python/cpython/pull/31270/files#diff-a19e0541aa4b8b56146c5d6e761608df7f2e8afeffaa8c3af930b17f25901a3c
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L379
Lib/asyncio/__init__.pyhttps://github.com/python/cpython/pull/31270/files#diff-6d8c6a7b5cda5773cc40309dcfeeeb120b25857274a13aba8f3c803d25397fdf
View file https://github.com/gvanrossum/cpython/blob/c1e5d64a27325f3c08668aa5d255038b991bd30e/Lib/asyncio/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/31270/{{ revealButtonHref }}
https://github.com/python/cpython/pull/31270/files#diff-6d8c6a7b5cda5773cc40309dcfeeeb120b25857274a13aba8f3c803d25397fdf
https://github.com/python/cpython/pull/31270/files#diff-6d8c6a7b5cda5773cc40309dcfeeeb120b25857274a13aba8f3c803d25397fdf
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L379
Lib/asyncio/base_tasks.pyhttps://github.com/python/cpython/pull/31270/files#diff-5eae152b5b94ab82986b91e37d76b9fbb194e533a613131166e292b16774d593
View file https://github.com/gvanrossum/cpython/blob/c1e5d64a27325f3c08668aa5d255038b991bd30e/Lib/asyncio/base_tasks.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/31270/{{ revealButtonHref }}
https://github.com/python/cpython/pull/31270/files#diff-5eae152b5b94ab82986b91e37d76b9fbb194e533a613131166e292b16774d593
https://github.com/python/cpython/pull/31270/files#diff-5eae152b5b94ab82986b91e37d76b9fbb194e533a613131166e292b16774d593
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L379
Lib/asyncio/taskgroups.pyhttps://github.com/python/cpython/pull/31270/files#diff-b90f92a0a4d63d1c6e9e82f28f7281db5fd468c356db4309e87c06a65f5606dc
View file https://github.com/gvanrossum/cpython/blob/c1e5d64a27325f3c08668aa5d255038b991bd30e/Lib/asyncio/taskgroups.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/31270/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L379
Lib/asyncio/tasks.pyhttps://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
View file https://github.com/gvanrossum/cpython/blob/c1e5d64a27325f3c08668aa5d255038b991bd30e/Lib/asyncio/tasks.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/31270/{{ revealButtonHref }}
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/31270/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
Please reload this pagehttps://github.com/python/cpython/pull/31270/files
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.