New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite TaskGroup and PersistentTaskGroup for Python 3.11 #36
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Refer asyncio.TaskGroup to handle multiple cancellation correctly. * Make it explicit that: - "async with" stays with the original TaskGroup semantics. - Demonstrate usage without "async with" for long-lived objects for server applications. - "shutdown()" allows abortion in the middle, even from another parent task. - Custom exception handlers are also treated as child tasks. (TODO: what if exceptions occur in exception handlers?)
* test: Split out naming-related tests
* docs: Update detailed class description * tests: Refactor variable names
* refactor: Promote taskgroup as a subpackage to handle version-specific imports * ci: Update GitHub workflows to run with Python 3.11 as well - Note: asyncio.TaskGroup is introduced in Alpha 5. * refactor: In Python 3.11, let it use the stdlib's TaskGroup implementation and BaseExceptionGroup for both backward and forward compatibility.
* Allow failures on typechec because currently there is typeshed support on the pre-release stdlib.
* a6 is not released yet, though the current main branch is a5.
Codecov Report
@@ Coverage Diff @@
## main #36 +/- ##
===========================================
- Coverage 78.63% 65.87% -12.77%
===========================================
Files 11 16 +5
Lines 941 1263 +322
===========================================
+ Hits 740 832 +92
- Misses 201 431 +230
Continue to review full report at Codecov.
|
achimnol
changed the title
Rewrite PersistentTaskgroup for Python 3.11
Rewrite TaskGroup and PersistentTaskGroup for Python 3.11
Mar 6, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR rewrites
PersistenTaskGroup
for Python 3.11.It works only for the latest Python 3.11 development version checked out from GitHub.It supports
TaskGroup
andPersistentTaskGroup
on Python 3.6 to 3.11, whileaiotools.TaskGroup
uses the stdlib's implementation on 3.11.0-alpha6 or later. The test suite ensures the same behavior of the custom implementation and the stdlib. At the time of writing, Python 3.11.0-alpha5 is the latest available build in GitHub Actions, so the CI runs only the custom implementations but I have checked the same test results on a local build of CPython.refs https://bugs.python.org/issue46843