Skip to content

Commit 53503ff

Browse files
GH-82604: fix docs about configuring selector (#97755)
1 parent a120b9f commit 53503ff

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
@@ -1632,9 +1632,12 @@ on Unix and :class:`ProactorEventLoop` on Windows.
16321632
import asyncio
16331633
import selectors
16341634

1635-
selector = selectors.SelectSelector()
1636-
loop = asyncio.SelectorEventLoop(selector)
1637-
asyncio.set_event_loop(loop)
1635+
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1636+
def new_event_loop(self):
1637+
selector = selectors.SelectSelector()
1638+
return asyncio.SelectorEventLoop(selector)
1639+
1640+
asyncio.set_event_loop_policy(MyPolicy())
16381641

16391642

16401643
.. availability:: Unix, Windows.

0 commit comments

Comments
 (0)