From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Tue, 4 Oct 2022 16:45:37 +0000 (+0530) Subject: GH-82604: fix docs about configuring selector (#97755) X-Git-Tag: v3.12.0a1~277 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53503ff60e9a4727af0d9a1096418675e72a0fae;p=thirdparty%2FPython%2Fcpython.git GH-82604: fix docs about configuring selector (#97755) --- 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.