From 31ba48ca921ec07a5ce8ebe796f21e955005e12d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 17 Jul 2022 00:20:07 +0100 Subject: [PATCH] use asyncio.Runner loop_factory on 3.11+ (#472) --- README.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index c78ba619..1712f824 100644 --- a/README.rst +++ b/README.rst @@ -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