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

(cherry picked from commit 53503ff60e)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-10-04 09:52:28 -07:00 committed by Pablo Galindo
parent 9d49bd4773
commit c6bf822a89
No known key found for this signature in database
GPG key ID: FFE87404168BD847

View file

@ -1638,9 +1638,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.