[Python-checkins] cpython (merge 3.6 -> default): Merge 3.6 (issue #28371)
yury.selivanov
python-checkins at python.org
Wed Oct 5 18:29:39 EDT 2016
https://hg.python.org/cpython/rev/893f65369fea
changeset: 104310:893f65369fea
parent: 104307:5913c2b1d80a
parent: 104309:c0d84c091db0
user: Yury Selivanov <yury at magic.io>
date: Wed Oct 05 18:29:33 2016 -0400
summary:
Merge 3.6 (issue #28371)
files:
Lib/asyncio/base_events.py | 3 +++
Lib/test/test_asyncio/test_base_events.py | 9 ++++++---
Misc/NEWS | 2 ++
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -606,6 +606,9 @@
if isinstance(func, events.Handle):
assert not args
assert not isinstance(func, events.TimerHandle)
+ warnings.warn(
+ "Passing Handle to loop.run_in_executor() is deprecated",
+ DeprecationWarning)
if func._cancelled:
f = self.create_future()
f.set_result(None)
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -358,7 +358,8 @@
h = asyncio.Handle(cb, (), self.loop)
h.cancel()
- f = self.loop.run_in_executor(None, h)
+ with self.assertWarnsRegex(DeprecationWarning, "Passing Handle"):
+ f = self.loop.run_in_executor(None, h)
self.assertIsInstance(f, asyncio.Future)
self.assertTrue(f.done())
self.assertIsNone(f.result())
@@ -373,12 +374,14 @@
self.loop.set_default_executor(executor)
- res = self.loop.run_in_executor(None, h)
+ with self.assertWarnsRegex(DeprecationWarning, "Passing Handle"):
+ res = self.loop.run_in_executor(None, h)
self.assertIs(f, res)
executor = mock.Mock()
executor.submit.return_value = f
- res = self.loop.run_in_executor(executor, h)
+ with self.assertWarnsRegex(DeprecationWarning, "Passing Handle"):
+ res = self.loop.run_in_executor(executor, h)
self.assertIs(f, res)
self.assertTrue(executor.submit.called)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -184,6 +184,8 @@
- Issue #28370: Speedup asyncio.StreamReader.readexactly.
Patch by Коренберг Марк.
+- Issue #28371: Deprecate passing asyncio.Handles to run_in_executor.
+
Windows
-------
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list