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 GitHub
parent 3263aaf83f
commit 0dcfe0f47e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

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