Commit 6ea29c5e authored by Victor Stinner's avatar Victor Stinner Committed by Yury Selivanov

bpo-34687: Make asynico use ProactorEventLoop by default (GH-9538)

parent c8c0249c
...@@ -23,6 +23,10 @@ All Platforms ...@@ -23,6 +23,10 @@ All Platforms
Windows Windows
======= =======
.. versionchanged:: 3.8
On Windows, :class:`ProactorEventLoop` is now the default event loop.
All event loops on Windows do not support the following methods: All event loops on Windows do not support the following methods:
* :meth:`loop.create_unix_connection` and * :meth:`loop.create_unix_connection` and
...@@ -67,16 +71,8 @@ Windows configuration. ...@@ -67,16 +71,8 @@ Windows configuration.
Subprocess Support on Windows Subprocess Support on Windows
----------------------------- -----------------------------
:class:`SelectorEventLoop` on Windows does not support subproceses. On Windows, the default event loop :class:`ProactorEventLoop` supports
On Windows, :class:`ProactorEventLoop` should be used instead:: subprocesses, whereas :class:`SelectorEventLoop` does not.
import asyncio
asyncio.set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(your_code())
The :meth:`policy.set_child_watcher() The :meth:`policy.set_child_watcher()
<AbstractEventLoopPolicy.set_child_watcher>` function is also <AbstractEventLoopPolicy.set_child_watcher>` function is also
......
...@@ -92,11 +92,23 @@ asyncio ships with the following built-in policies: ...@@ -92,11 +92,23 @@ asyncio ships with the following built-in policies:
.. class:: DefaultEventLoopPolicy .. class:: DefaultEventLoopPolicy
The default asyncio policy. Uses :class:`SelectorEventLoop` The default asyncio policy. Uses :class:`SelectorEventLoop`
on both Unix and Windows platforms. on Unix and :class:`ProactorEventLoop` on Windows.
There is no need to install the default policy manually. asyncio There is no need to install the default policy manually. asyncio
is configured to use the default policy automatically. is configured to use the default policy automatically.
.. versionchanged:: 3.8
On Windows, :class:`ProactorEventLoop` is now used by default.
.. class:: WindowsSelectorEventLoopPolicy
An alternative event loop policy that uses the
:class:`SelectorEventLoop` event loop implementation.
Availability: Windows.
.. class:: WindowsProactorEventLoopPolicy .. class:: WindowsProactorEventLoopPolicy
......
...@@ -116,6 +116,11 @@ New Modules ...@@ -116,6 +116,11 @@ New Modules
Improved Modules Improved Modules
================ ================
asyncio
-------
On Windows, the default event loop is now :class:`~asyncio.ProactorEventLoop`.
os.path os.path
------- -------
......
...@@ -811,4 +811,4 @@ class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): ...@@ -811,4 +811,4 @@ class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory = ProactorEventLoop _loop_factory = ProactorEventLoop
DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy DefaultEventLoopPolicy = WindowsProactorEventLoopPolicy
...@@ -1014,7 +1014,7 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase): ...@@ -1014,7 +1014,7 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.loop = asyncio.new_event_loop() self.loop = asyncio.SelectorEventLoop()
self.set_event_loop(self.loop) self.set_event_loop(self.loop)
@mock.patch('socket.getnameinfo') @mock.patch('socket.getnameinfo')
......
...@@ -816,7 +816,8 @@ os.close(fd) ...@@ -816,7 +816,8 @@ os.close(fd)
addr = q.get() addr = q.get()
# Should not be stuck in an infinite loop. # Should not be stuck in an infinite loop.
with self.assertRaises((ConnectionResetError, BrokenPipeError)): with self.assertRaises((ConnectionResetError, ConnectionAbortedError,
BrokenPipeError)):
self.loop.run_until_complete(client(*addr)) self.loop.run_until_complete(client(*addr))
# Clean up the thread. (Only on success; on failure, it may # Clean up the thread. (Only on success; on failure, it may
......
On Windows, asyncio now uses ProactorEventLoop, instead of
SelectorEventLoop, by default.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment