Skip to content

docs: update uvloop guide to avoid deprecated EventLoopPolicy#1368

Open
indoor47 wants to merge 2 commits intopytest-dev:mainfrom
indoor47:fix/uvloop-eventlooppolicy-1355
Open

docs: update uvloop guide to avoid deprecated EventLoopPolicy#1368
indoor47 wants to merge 2 commits intopytest-dev:mainfrom
indoor47:fix/uvloop-eventlooppolicy-1355

Conversation

@indoor47
Copy link

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 using asyncio.get_event_loop_policy() and policy.set_event_loop_class(uvloop.EventLoop).

Changes

  • Added import asyncio to the uvloop guide code example
  • Replaced uvloop.EventLoopPolicy() with asyncio.get_event_loop_policy() + set_event_loop_class(uvloop.EventLoop) pattern
  • This avoids the deprecation warning emitted by uvloop.EventLoopPolicy in uvloop >= 0.20

Why

Users following the current guide get a DeprecationWarning from uvloop when using the EventLoopPolicy approach. The new pattern is the officially recommended way to integrate uvloop per the uvloop changelog.

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-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.64%. Comparing base (173cb39) to head (f5ac994).

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.
📢 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.

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proof? Docs? Tests? Change note?

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.

3 participants