summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-05 00:44:10 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-12-05 00:44:10 (GMT)
commitf3e2e09213ecac36c3c3634a06cb7badf3e4217e (patch)
tree47720db212aeb42092da2ce37290d16161173bcc /Lib/test/test_asyncio/test_base_events.py
parent4c85ec99f39bb6687f6fb0d23c6a7daedcde990e (diff)
downloadcpython-f3e2e09213ecac36c3c3634a06cb7badf3e4217e.zip
cpython-f3e2e09213ecac36c3c3634a06cb7badf3e4217e.tar.gz
cpython-f3e2e09213ecac36c3c3634a06cb7badf3e4217e.tar.bz2
Closes #22429, asyncio: Fix EventLoop.run_until_complete(), don't stop the
event loop if a BaseException is raised, because the event loop is already stopped.
Diffstat (limited to 'Lib/test/test_asyncio/test_base_events.py')
-rw-r--r--Lib/test/test_asyncio/test_base_events.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 0aa0117..db9d732 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -638,6 +638,31 @@ class BaseEventLoopTests(test_utils.TestCase):
self.assertFalse(self.loop.call_exception_handler.called)
+ def test_run_until_complete_baseexception(self):
+ # Python issue #22429: run_until_complete() must not schedule a pending
+ # call to stop() if the future raised a BaseException
+ @asyncio.coroutine
+ def raise_keyboard_interrupt():
+ raise KeyboardInterrupt
+
+ self.loop._process_events = mock.Mock()
+
+ try:
+ self.loop.run_until_complete(raise_keyboard_interrupt())
+ except KeyboardInterrupt:
+ pass
+
+ def func():
+ self.loop.stop()
+ func.called = True
+ func.called = False
+ try:
+ self.loop.call_soon(func)
+ self.loop.run_forever()
+ except KeyboardInterrupt:
+ pass
+ self.assertTrue(func.called)
+
class MyProto(asyncio.Protocol):
done = None