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

This commit is contained in:
Kumar Aditya 2022-10-04 22:15:37 +05:30 committed by GitHub
parent a120b9f25d
commit 53503ff60e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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.