Skip to content

Commit 31ba48c

Browse files
authored
use asyncio.Runner loop_factory on 3.11+ (#472)
1 parent 3aacb35 commit 31ba48c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,23 @@ uvloop with::
5353
Using uvloop
5454
------------
5555

56-
Call ``uvloop.install()`` before calling ``asyncio.run()`` or
57-
manually creating an asyncio event loop:
58-
5956
.. code:: python
6057
6158
import asyncio
59+
import sys
60+
6261
import uvloop
6362
6463
async def main():
6564
# Main entry-point.
6665
...
6766
68-
uvloop.install()
69-
asyncio.run(main())
67+
if sys.version_info >= (3, 11)
68+
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
69+
runner.run(main())
70+
else:
71+
uvloop.install()
72+
asyncio.run(main())
7073
7174
7275
Building From Source

0 commit comments

Comments
 (0)