]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-82604: fix docs about configuring selector (GH-97755)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 4 Oct 2022 16:52:35 +0000 (09:52 -0700)
committerGitHub <noreply@github.com>
Tue, 4 Oct 2022 16:52:35 +0000 (09:52 -0700)
(cherry picked from commit 53503ff60e9a4727af0d9a1096418675e72a0fae)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Doc/library/asyncio-eventloop.rst

index a6250be6be55fa24e9ff4e00c868a13dbef2f75a..d2f7869908022d5e1caa1b5fa7518e551370eaf7 100644 (file)
@@ -1523,9 +1523,12 @@ on Unix and :class:`ProactorEventLoop` on Windows.
       import asyncio
       import selectors
 
-      selector = selectors.SelectSelector()
-      loop = asyncio.SelectorEventLoop(selector)
-      asyncio.set_event_loop(loop)
+      class MyPolicy(asyncio.DefaultEventLoopPolicy):
+         def new_event_loop(self):
+            selector = selectors.SelectSelector()
+            return asyncio.SelectorEventLoop(selector)
+
+      asyncio.set_event_loop_policy(MyPolicy())
 
 
    .. availability:: Unix, Windows.