Skip to content

Commit

Permalink
[asyncio] bpo-30423: add regression test for orphan future causes "Ru…
Browse files Browse the repository at this point in the history
…ntimeError: Event loop stopped before Future completed." (python#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."
  • Loading branch information
jimmylai authored and asvetlov committed Nov 1, 2017
1 parent 894ebd0 commit d1e3403
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,22 @@ def test_run_until_complete_loop(self):
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']

Expand Down

0 comments on commit d1e3403

Please sign in to comment.