Skip to content

Commit

Permalink
use asyncio.Runner loop_factory on 3.11+ (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Jul 16, 2022
1 parent 3aacb35 commit 31ba48c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions README.rst
Expand Up @@ -53,20 +53,23 @@ uvloop with::
Using uvloop
------------

Call ``uvloop.install()`` before calling ``asyncio.run()`` or
manually creating an asyncio event loop:

.. code:: python
import asyncio
import sys
import uvloop
async def main():
# Main entry-point.
...
uvloop.install()
asyncio.run(main())
if sys.version_info >= (3, 11)
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
runner.run(main())
else:
uvloop.install()
asyncio.run(main())
Building From Source
Expand Down

0 comments on commit 31ba48c

Please sign in to comment.