docs: update uvloop guide to avoid deprecated EventLoopPolicy#1368
Open
indoor47 wants to merge 2 commits intopytest-dev:mainfrom
Open
docs: update uvloop guide to avoid deprecated EventLoopPolicy#1368indoor47 wants to merge 2 commits intopytest-dev:mainfrom
indoor47 wants to merge 2 commits intopytest-dev:mainfrom
Conversation
Fixes pytest-dev#1355. Replace the deprecated uvloop.EventLoopPolicy() with the modern pattern using asyncio.get_event_loop_policy() and setting the event loop class directly. This maintains compatibility with recent uvloop versions while providing the same functionality.
…guide shed (isort) requires a blank line separating stdlib imports from third-party imports. Add the blank line between `import asyncio` and `import pytest` / `import uvloop`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1368 +/- ##
=======================================
Coverage 93.64% 93.64%
=======================================
Files 2 2
Lines 409 409
Branches 44 44
=======================================
Hits 383 383
Misses 20 20
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
webknjaz
requested changes
Feb 27, 2026
Member
webknjaz
left a comment
There was a problem hiding this comment.
Proof? Docs? Tests? Change note?
This file contains hidden or 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
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.
Summary
The uvloop integration guide uses
uvloop.EventLoopPolicy()directly, which is deprecated in recent versions of uvloop. This update replaces it with the recommended pattern usingasyncio.get_event_loop_policy()andpolicy.set_event_loop_class(uvloop.EventLoop).Changes
import asyncioto the uvloop guide code exampleuvloop.EventLoopPolicy()withasyncio.get_event_loop_policy()+set_event_loop_class(uvloop.EventLoop)patternuvloop.EventLoopPolicyin uvloop >= 0.20Why
Users following the current guide get a
DeprecationWarningfrom uvloop when using theEventLoopPolicyapproach. The new pattern is the officially recommended way to integrate uvloop per the uvloop changelog.