Navigation Menu

Skip to content
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
merged 37 commits into from Mar 6, 2022

Conversation

achimnol
Copy link
Owner

@achimnol achimnol commented Feb 26, 2022

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 and PersistentTaskGroup on Python 3.6 to 3.11, while aiotools.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

* 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?)
@achimnol achimnol self-assigned this Feb 26, 2022
* 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
Copy link

codecov bot commented Mar 6, 2022

Codecov Report

Merging #36 (806bafc) into main (0051cd9) will decrease coverage by 12.76%.
The diff coverage is 48.51%.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
src/aiotools/__init__.py 93.33% <ø> (-0.42%) ⬇️
src/aiotools/taskgroup/base.py 0.00% <0.00%> (ø)
src/aiotools/taskgroup/persistent.py 0.00% <0.00%> (ø)
src/aiotools/taskgroup/__init__.py 61.53% <61.53%> (ø)
src/aiotools/taskgroup/types.py 72.50% <72.50%> (ø)
src/aiotools/taskgroup/persistent_compat.py 82.85% <82.85%> (ø)
src/aiotools/taskgroup/base_compat.py 81.61% <100.00%> (ø)
src/aiotools/taskgroup/common.py 100.00% <100.00%> (ø)
src/aiotools/timer.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0051cd9...806bafc. Read the comment docs.

@achimnol achimnol marked this pull request as ready for review March 6, 2022 06:54
@achimnol achimnol merged commit 446ffec into main Mar 6, 2022
@achimnol achimnol deleted the feature/ptaskgroup-v2 branch March 6, 2022 09:48
@achimnol 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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant