Skip to content

Commit 0dcfe0f

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 3263aaf commit 0dcfe0f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Doc/library/asyncio-eventloop.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -1611,9 +1611,12 @@ on Unix and :class:`ProactorEventLoop` on Windows.
16111611
import asyncio
16121612
import selectors
16131613

1614-
selector = selectors.SelectSelector()
1615-
loop = asyncio.SelectorEventLoop(selector)
1616-
asyncio.set_event_loop(loop)
1614+
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1615+
def new_event_loop(self):
1616+
selector = selectors.SelectSelector()
1617+
return asyncio.SelectorEventLoop(selector)
1618+
1619+
asyncio.set_event_loop_policy(MyPolicy())
16171620

16181621

16191622
.. availability:: Unix, Windows.

0 commit comments

Comments
 (0)