Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace event loops with asyncio.Runner#1152

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@seifertm
Copy link
Contributor

Previously, pytest-asyncio used a combination of low-level asyncio functions to manage event loops. This patch replaces the low-level functions with the use of asyncio.Runner.

The runner takes care of cancelling remaining tasks at the end of its scope, avoiding errors about pending tasks. This also fixes an issue that caused RuntimeErrors in abanoned tasks that called functions which depend on a running loop.

Moreover, the use of asyncio.Runner and its backport allows backporting the propagation of contextvars from fixtures to tests to Python 3.9 and Python 3.10.

Supersedes#309
Closes#127
Closes#200
Closes#878
Partially addresses#1032

SyntaxColoring, dantownsend, bcmills, samypr100, and butla reacted with hooray emoji
Previously, pytest-asyncio used a combination of low-level asyncio functions to manage event loops. This patch replaces the low-level functions with the use of asyncio.Runner. The runner takes care of cancelling remaining tasks at the end of its scope, avoiding errors about pending tasks. This also fixes an issue that caused RuntimeErrors in abanoned tasks that called functions which depend on a running loop.Moreover, the use of asyncio.Runner allows backporting the propagation of contextvars from fixtures to tests to Python 3.9 and Python 3.10.
@seifertmseifertm added this to thev1.1 milestoneJun 24, 2025
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is86.48649% with5 lines in your changes missing coverage. Please review.

Project coverage is 89.01%. Comparing base(6c9914b) to head(ce15320).

Files with missing linesPatch %Lines
pytest_asyncio/plugin.py86.48%4 Missing and 1 partial⚠️
Additional details and impacted files
@@            Coverage Diff             @@##             main    #1152      +/-   ##==========================================- Coverage   89.40%   89.01%   -0.39%==========================================  Files           2        2                Lines         434      428       -6       Branches       51       51              ==========================================- Hits          388      381       -7- Misses         31       33       +2+ Partials       15       14       -1

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@seifertmseifertm added this pull request to themerge queueJun 25, 2025
Merged via the queue intopytest-dev:main with commitf9c5d67Jun 25, 2025
18 of 19 checks passed
@seifertmseifertm deleted the replace-event-loops-with-asyncio-runner branchJune 25, 2025 17:04
@seifertmseifertm restored the replace-event-loops-with-asyncio-runner branchJune 25, 2025 17:05
@seifertmseifertm deleted the replace-event-loops-with-asyncio-runner branchJune 25, 2025 18:05
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@TincheTincheAwaiting requested review from TincheTinche is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

v1.1

Development

Successfully merging this pull request may close these issues.

Task finalizers run outside of event loop Clean up pending tasks when event_loop fixture leaves scope ContextVar not propagated from fixture to test

2 participants

@seifertm@codecov-commenter

[8]ページ先頭

©2009-2025 Movatter.jp