[Python-checkins] bpo-34687: Make asynico use ProactorEventLoop by default (GH-9538)
Yury Selivanov
webhook-mailer at python.org
Tue Sep 25 11:27:21 EDT 2018
https://github.com/python/cpython/commit/6ea29c5e90dde6c240bd8e0815614b52ac307ea1
commit: 6ea29c5e90dde6c240bd8e0815614b52ac307ea1
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: Yury Selivanov <yury at magic.io>
date: 2018年09月25日T11:27:08-04:00
summary:
bpo-34687: Make asynico use ProactorEventLoop by default (GH-9538)
files:
A Misc/NEWS.d/next/Library/2018-09-24-17-14-57.bpo-34687.Fku_8S.rst
M Doc/library/asyncio-platforms.rst
M Doc/library/asyncio-policy.rst
M Doc/whatsnew/3.8.rst
M Lib/asyncio/windows_events.py
M Lib/test/test_asyncio/test_base_events.py
M Lib/test/test_asyncio/test_streams.py
diff --git a/Doc/library/asyncio-platforms.rst b/Doc/library/asyncio-platforms.rst
index f8ecb58d3a01..81d840e23277 100644
--- a/Doc/library/asyncio-platforms.rst
+++ b/Doc/library/asyncio-platforms.rst
@@ -23,6 +23,10 @@ All Platforms
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:
* :meth:`loop.create_unix_connection` and
@@ -67,16 +71,8 @@ Windows configuration.
Subprocess Support on Windows
-----------------------------
-:class:`SelectorEventLoop` on Windows does not support subproceses.
-On Windows, :class:`ProactorEventLoop` should be used instead::
-
- import asyncio
-
- asyncio.set_event_loop_policy(
- asyncio.WindowsProactorEventLoopPolicy())
-
- asyncio.run(your_code())
-
+On Windows, the default event loop :class:`ProactorEventLoop` supports
+subprocesses, whereas :class:`SelectorEventLoop` does not.
The :meth:`policy.set_child_watcher()
<AbstractEventLoopPolicy.set_child_watcher>` function is also
diff --git a/Doc/library/asyncio-policy.rst b/Doc/library/asyncio-policy.rst
index 42f936da468e..560f8b3135e1 100644
--- a/Doc/library/asyncio-policy.rst
+++ b/Doc/library/asyncio-policy.rst
@@ -92,11 +92,23 @@ asyncio ships with the following built-in policies:
.. class:: DefaultEventLoopPolicy
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
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
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index e37a70f32d99..89764c8cd2bc 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -116,6 +116,11 @@ New Modules
Improved Modules
================
+asyncio
+-------
+
+On Windows, the default event loop is now :class:`~asyncio.ProactorEventLoop`.
+
os.path
-------
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index fdde8e9e0bf4..772ddf4dfebd 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -811,4 +811,4 @@ class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory = ProactorEventLoop
-DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy
+DefaultEventLoopPolicy = WindowsProactorEventLoopPolicy
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index fe3c38371d0c..95f4f6b82d53 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -1014,7 +1014,7 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
def setUp(self):
super().setUp()
- self.loop = asyncio.new_event_loop()
+ self.loop = asyncio.SelectorEventLoop()
self.set_event_loop(self.loop)
@mock.patch('socket.getnameinfo')
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py
index d8e371510dea..c529e5208c99 100644
--- a/Lib/test/test_asyncio/test_streams.py
+++ b/Lib/test/test_asyncio/test_streams.py
@@ -816,7 +816,8 @@ def server():
addr = q.get()
# 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))
# Clean up the thread. (Only on success; on failure, it may
diff --git a/Misc/NEWS.d/next/Library/2018-09-24-17-14-57.bpo-34687.Fku_8S.rst b/Misc/NEWS.d/next/Library/2018-09-24-17-14-57.bpo-34687.Fku_8S.rst
new file mode 100644
index 000000000000..0e203c4f2786
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-09-24-17-14-57.bpo-34687.Fku_8S.rst
@@ -0,0 +1,2 @@
+On Windows, asyncio now uses ProactorEventLoop, instead of
+SelectorEventLoop, by default.
More information about the Python-checkins
mailing list