[Python-checkins] GH-82604: fix docs about configuring selector (#97755)

gvanrossum webhook-mailer at python.org
Tue Oct 4 12:45:46 EDT 2022


https://github.com/python/cpython/commit/53503ff60e9a4727af0d9a1096418675e72a0fae
commit: 53503ff60e9a4727af0d9a1096418675e72a0fae
branch: main
author: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2022-10-04T09:45:37-07:00
summary:

GH-82604: fix docs about configuring selector (#97755)

files:
M Doc/library/asyncio-eventloop.rst

diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index 0a960ab38b49..c51990eff8de 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -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.



More information about the Python-checkins mailing list