Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,20 +530,25 @@ def test_run_until_complete_loop(self):
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)
class ShowStopper(BaseException):
pass

self.loop.close()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
async def foo(delay):
await asyncio.sleep(delay, loop=self.loop)

def throw():
raise ShowStopper

self.loop._process_events = mock.Mock()
self.loop.call_soon(throw)
try:
with mock.patch('asyncio.base_events.BaseEventLoop.run_forever',
side_effect=Exception):
loop.run_until_complete(foo())
except:
self.loop.run_until_complete(foo(0.1))
except ShowStopper:
pass
loop.run_until_complete(foo(0.1))
loop.close()

# This call fails if run_until_complete does not clean up
# done-callback for the previous future.
self.loop.run_until_complete(foo(0.2))

def test_subprocess_exec_invalid_args(self):
args = [sys.executable, '-c', 'pass']
Expand Down