]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-82604: fix docs about configuring selector (#97755)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Tue, 4 Oct 2022 16:45:37 +0000 (22:15 +0530)
committerGitHub <noreply@github.com>
Tue, 4 Oct 2022 16:45:37 +0000 (09:45 -0700)
Doc/library/asyncio-eventloop.rst

index 0a960ab38b495b48c34b60d00c7da65ef68746fb..c51990eff8deec0517aab9ac216cdc36382f1f18 100644 (file)
@@ -1632,9 +1632,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.