mirror of
https://github.com/python/cpython.git
synced 2025-10-04 22:20:46 +00:00
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:
parent
3263aaf83f
commit
0dcfe0f47e
1 changed files with 6 additions and 3 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue