summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/base_events.py3
-rw-r--r--Lib/test/test_asyncio/test_base_events.py9
2 files changed, 9 insertions, 3 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 86b4291..5b5fcde 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -606,6 +606,9 @@ class BaseEventLoop(events.AbstractEventLoop):
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
index 362ab06..a9aba0f 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -358,7 +358,8 @@ class BaseEventLoopTests(test_utils.TestCase):
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 @@ class BaseEventLoopTests(test_utils.TestCase):
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)