bpo-34687: Make asynico use ProactorEventLoop by default (GH-9538) · python/cpython@6ea29c5 (original) (raw)
7 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -23,6 +23,10 @@ All Platforms | ||
23 | 23 | Windows |
24 | 24 | ======= |
25 | 25 | |
26 | +.. versionchanged:: 3.8 | |
27 | + | |
28 | + On Windows, :class:`ProactorEventLoop` is now the default event loop. | |
29 | + | |
26 | 30 | All event loops on Windows do not support the following methods: |
27 | 31 | |
28 | 32 | * :meth:`loop.create_unix_connection` and |
@@ -67,16 +71,8 @@ Windows configuration. | ||
67 | 71 | Subprocess Support on Windows |
68 | 72 | ----------------------------- |
69 | 73 | |
70 | -:class:`SelectorEventLoop` on Windows does not support subproceses. | |
71 | -On Windows, :class:`ProactorEventLoop` should be used instead:: | |
72 | - | |
73 | - import asyncio | |
74 | - | |
75 | - asyncio.set_event_loop_policy( | |
76 | - asyncio.WindowsProactorEventLoopPolicy()) | |
77 | - | |
78 | - asyncio.run(your_code()) | |
79 | - | |
74 | +On Windows, the default event loop :class:`ProactorEventLoop` supports | |
75 | +subprocesses, whereas :class:`SelectorEventLoop` does not. | |
80 | 76 | |
81 | 77 | The :meth:`policy.set_child_watcher() |
82 | 78 | <AbstractEventLoopPolicy.set_child_watcher>` function is also |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -92,11 +92,23 @@ asyncio ships with the following built-in policies: | ||
92 | 92 | .. class:: DefaultEventLoopPolicy |
93 | 93 | |
94 | 94 | The default asyncio policy. Uses :class:`SelectorEventLoop` |
95 | - on both Unix and Windows platforms. | |
95 | + on Unix and :class:`ProactorEventLoop` on Windows. | |
96 | 96 | |
97 | 97 | There is no need to install the default policy manually. asyncio |
98 | 98 | is configured to use the default policy automatically. |
99 | 99 | |
100 | + .. versionchanged:: 3.8 | |
101 | + | |
102 | + On Windows, :class:`ProactorEventLoop` is now used by default. | |
103 | + | |
104 | + | |
105 | +.. class:: WindowsSelectorEventLoopPolicy | |
106 | + | |
107 | + An alternative event loop policy that uses the | |
108 | +:class:`SelectorEventLoop` event loop implementation. | |
109 | + | |
110 | + Availability: Windows. | |
111 | + | |
100 | 112 | |
101 | 113 | .. class:: WindowsProactorEventLoopPolicy |
102 | 114 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -116,6 +116,11 @@ New Modules | ||
116 | 116 | Improved Modules |
117 | 117 | ================ |
118 | 118 | |
119 | +asyncio | |
120 | +------- | |
121 | + | |
122 | +On Windows, the default event loop is now :class:`~asyncio.ProactorEventLoop`. | |
123 | + | |
119 | 124 | os.path |
120 | 125 | ------- |
121 | 126 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -811,4 +811,4 @@ class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): | ||
811 | 811 | _loop_factory = ProactorEventLoop |
812 | 812 | |
813 | 813 | |
814 | -DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy | |
814 | +DefaultEventLoopPolicy = WindowsProactorEventLoopPolicy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1014,7 +1014,7 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase): | ||
1014 | 1014 | |
1015 | 1015 | def setUp(self): |
1016 | 1016 | super().setUp() |
1017 | -self.loop = asyncio.new_event_loop() | |
1017 | +self.loop = asyncio.SelectorEventLoop() | |
1018 | 1018 | self.set_event_loop(self.loop) |
1019 | 1019 | |
1020 | 1020 | @mock.patch('socket.getnameinfo') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -816,7 +816,8 @@ async def client(host, port): | ||
816 | 816 | addr = q.get() |
817 | 817 | |
818 | 818 | # Should not be stuck in an infinite loop. |
819 | -with self.assertRaises((ConnectionResetError, BrokenPipeError)): | |
819 | +with self.assertRaises((ConnectionResetError, ConnectionAbortedError, | |
820 | +BrokenPipeError)): | |
820 | 821 | self.loop.run_until_complete(client(*addr)) |
821 | 822 | |
822 | 823 | # Clean up the thread. (Only on success; on failure, it may |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | +On Windows, asyncio now uses ProactorEventLoop, instead of | |
2 | +SelectorEventLoop, by default. |