[Python-checkins] Fix check for run_in_executor on closed loop. (#4996)

Andrew Svetlov webhook-mailer at python.org
Sat Dec 23 16:03:30 EST 2017


https://github.com/python/cpython/commit/a330f483e2d05f3ad1780f0542ecd8d2b0dda5df
commit: a330f483e2d05f3ad1780f0542ecd8d2b0dda5df
branch: master
author: Andrew Svetlov <andrew.svetlov at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-12-23T23:03:27+02:00
summary:

Fix check for run_in_executor on closed loop. (#4996)

files:
M Lib/test/test_asyncio/test_events.py

diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index e5e41fc1a87..79e8d79e6b1 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1842,14 +1842,18 @@ def test():
             self.loop.call_later(1.0, func)
         with self.assertRaises(RuntimeError):
             self.loop.call_at(self.loop.time() + .0, func)
-        with self.assertRaises(RuntimeError):
-            self.loop.run_until_complete(
-                self.loop.run_in_executor(None, func))
         with self.assertRaises(RuntimeError):
             self.loop.create_task(coro)
         with self.assertRaises(RuntimeError):
             self.loop.add_signal_handler(signal.SIGTERM, func)
 
+        # run_in_executor test is tricky: the method is a coroutine,
+        # but run_until_complete cannot be called on closed loop.
+        # Thus iterate once explicitly.
+        with self.assertRaises(RuntimeError):
+            it = self.loop.run_in_executor(None, func).__await__()
+            next(it)
+
 
 class SubprocessTestsMixin:
 



More information about the Python-checkins mailing list