From 5426de9a23e393789c8d85569a305037bada2ac9 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 1 Jun 2022 21:14:03 +0100 Subject: [PATCH 1/2] use asyncio.Runner loop_factory on 3.11+ --- README.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index c78ba619..631f722c 100644 --- a/README.rst +++ b/README.rst @@ -53,9 +53,6 @@ uvloop with:: Using uvloop ------------ -Call ``uvloop.install()`` before calling ``asyncio.run()`` or -manually creating an asyncio event loop: - .. code:: python import asyncio @@ -65,8 +62,12 @@ manually creating an asyncio event loop: # 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 From a5bf891f7d83cd52a972b4c3b6aa6dffe2fcf761 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 1 Jun 2022 21:15:05 +0100 Subject: [PATCH 2/2] Update README.rst --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 631f722c..1712f824 100644 --- a/README.rst +++ b/README.rst @@ -56,6 +56,8 @@ Using uvloop .. code:: python import asyncio + import sys + import uvloop async def main():