Skip to content

Commit 09803ca

Browse files
author
Adam (indoor47)
committed
docs: update uvloop guide to avoid deprecated EventLoopPolicy
Fixes #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.
1 parent 173cb39 commit 09803ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/how-to-guides/uvloop.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ Replace the default event loop policy in your *conftest.py:*
77

88
.. code-block:: python
99
10+
import asyncio
1011
import pytest
1112
import uvloop
1213
1314
1415
@pytest.fixture(scope="session")
1516
def event_loop_policy():
16-
return uvloop.EventLoopPolicy()
17+
policy = asyncio.get_event_loop_policy()
18+
policy.set_event_loop_class(uvloop.EventLoop)
19+
return policy
1720
1821
You may choose to limit the scope of the fixture to *package,* *module,* or *class,* if you only want a subset of your tests to run with uvloop.

0 commit comments

Comments
 (0)