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

Appearance settings

fix: Use asyncio.new_event_loop() to create event loop for tests#1138

Merged
csmarchbanks merged 2 commits intoprometheus:masterprometheus/client_python:masterfrom
mgorny:asyncio-testsmgorny/client_python:asyncio-testsCopy head branch name to clipboard
Sep 12, 2025
Merged

fix: Use asyncio.new_event_loop() to create event loop for tests#1138
csmarchbanks merged 2 commits intoprometheus:masterprometheus/client_python:masterfrom
mgorny:asyncio-testsmgorny/client_python:asyncio-testsCopy head branch name to clipboard

Conversation

@mgorny
Copy link
Contributor

@mgorny mgorny commented Sep 12, 2025

Replace the use of asyncio.get_event_loop() with more appropriate asyncio.new_event_loop() to create event loops for testing. The former used to be a wrapper that either returned the currently running event loop or created a new one, but the latter behavior was deprecated and removed in Python 3.14. Since the tests are always run in a synchronous context, and they always run the obtained event loop to completion, just always create a new event loop.

Fixes #1137

Replace the use of `asyncio.get_event_loop()` with more appropriate
`asyncio.new_event_loop()` to create event loops for testing.
The former used to be a wrapper that either returned the currently
running event loop or created a new one, but the latter behavior was
deprecated and removed in Python 3.14.  Since the tests are always run
in a synchronous context, and they always run the obtained event loop
to completion, just always create a new event loop.

Fixes prometheus#1137

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Remove the `asgiref` pin linked to prometheus#1020.  I can't reproduce the issue
anymore with the current `asgiref` versions, and the pin actually
breaks the tests with the `asyncio` event loop fixes.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
@mgorny
Copy link
Contributor Author

mgorny commented Sep 12, 2025

@csmarchbanks

@csmarchbanks
Copy link
Member

Thank you!

@csmarchbanks csmarchbanks merged commit f947140 into prometheus:master Sep 12, 2025
11 checks passed
@mgorny mgorny deleted the asyncio-tests branch September 13, 2025 04:31
@mgorny
Copy link
Contributor Author

mgorny commented Sep 13, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASGI tests are failing on Python 3.14 due to missing event loop

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.