diff options
author | jimmylai <albert_chs@yahoo.com.tw> | 2017-11-01 13:54:45 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2017-11-01 13:54:45 (GMT) |
commit | d1e34031f68a3c7523a5376575c87cd0fea2425c (patch) | |
tree | 344c1bc0d114a58813579a53d718826bfe2b5ca3 /Lib/test | |
parent | 894ebd065e02debf20c0657d26020ecc42b7534f (diff) | |
download | cpython-d1e34031f68a3c7523a5376575c87cd0fea2425c.zip cpython-d1e34031f68a3c7523a5376575c87cd0fea2425c.tar.gz cpython-d1e34031f68a3c7523a5376575c87cd0fea2425c.tar.bz2 |
[asyncio] bpo-30423: add regression test for orphan future causes "RuntimeError: Event loop stopped before Future completed." (#3295)
* call remove_done_callback in finally section
* [asyncio] bpo-30423 bug: add regression test for orphan future causes "RuntimeError: Event loop stopped before Future completed."
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_base_events.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index a0ce9fa..6fdb593 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -529,6 +529,22 @@ class BaseEventLoopTests(test_utils.TestCase): self.assertRaises(ValueError, other_loop.run_until_complete, task) + def test_run_until_complete_loop_orphan_future_close_loop(self): + async def foo(sec=0): + await asyncio.sleep(sec) + + self.loop.close() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + with mock.patch('asyncio.base_events.BaseEventLoop.run_forever', + side_effect=Exception): + loop.run_until_complete(foo()) + except: + pass + loop.run_until_complete(foo(0.1)) + loop.close() + def test_subprocess_exec_invalid_args(self): args = [sys.executable, '-c', 'pass'] |