changeset: 104308:c8e71ddf1db5 branch: 3.5 parent: 104305:b3ef922e6f26 user: Yury Selivanov date: Wed Oct 05 18:28:09 2016 -0400 files: Lib/asyncio/base_events.py Lib/test/test_asyncio/test_base_events.py Misc/NEWS description: Issue #28371: Deprecate passing asyncio.Handles to run_in_executor. diff -r b3ef922e6f26 -r c8e71ddf1db5 Lib/asyncio/base_events.py --- a/Lib/asyncio/base_events.py Wed Oct 05 18:01:12 2016 -0400 +++ b/Lib/asyncio/base_events.py Wed Oct 05 18:28:09 2016 -0400 @@ -605,6 +605,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 -r b3ef922e6f26 -r c8e71ddf1db5 Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py Wed Oct 05 18:01:12 2016 -0400 +++ b/Lib/test/test_asyncio/test_base_events.py Wed Oct 05 18:28:09 2016 -0400 @@ -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 -r b3ef922e6f26 -r c8e71ddf1db5 Misc/NEWS --- a/Misc/NEWS Wed Oct 05 18:01:12 2016 -0400 +++ b/Misc/NEWS Wed Oct 05 18:28:09 2016 -0400 @@ -356,6 +356,8 @@ - Issue #28370: Speedup asyncio.StreamReader.readexactly. Patch by Коренберг Марк. +- Issue #28371: Deprecate passing asyncio.Handles to run_in_executor. + IDLE ----