Skip to content

Commit f4e2686

Browse files
GH-82604: fix docs about configuring selector (GH-97755)
(cherry picked from commit 53503ff) Co-authored-by: Kumar Aditya <[email protected]>
1 parent 2911521 commit f4e2686

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,9 +1523,12 @@ on Unix and :class:`ProactorEventLoop` on Windows.
15231523
import asyncio
15241524
import selectors
15251525

1526-
selector = selectors.SelectSelector()
1527-
loop = asyncio.SelectorEventLoop(selector)
1528-
asyncio.set_event_loop(loop)
1526+
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1527+
def new_event_loop(self):
1528+
selector = selectors.SelectSelector()
1529+
return asyncio.SelectorEventLoop(selector)
1530+
1531+
asyncio.set_event_loop_policy(MyPolicy())
15291532

15301533

15311534
.. availability:: Unix, Windows.

0 commit comments

Comments
 (0)