Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4088ad9

Browse files
committed
Issue #23475, asyncio: Fix test_close_kill_running()
Really kill the child process, don't mock completly the Popen.kill() method. This change fix memory leaks and reference leaks.
1 parent 4cb814c commit 4088ad9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,19 @@ def kill_running():
355355
create = self.loop.subprocess_exec(asyncio.SubprocessProtocol,
356356
*PROGRAM_BLOCKED)
357357
transport, protocol = yield from create
358+
359+
kill_called = False
360+
def kill():
361+
nonlocal kill_called
362+
kill_called = True
363+
orig_kill()
364+
358365
proc = transport.get_extra_info('subprocess')
359-
proc.kill = mock.Mock()
366+
orig_kill = proc.kill
367+
proc.kill = kill
360368
returncode = transport.get_returncode()
361369
transport.close()
362-
return (returncode, proc.kill.called)
370+
return (returncode, kill_called)
363371

364372
# Ignore "Close running child process: kill ..." log
365373
with test_utils.disable_logger():

0 commit comments

Comments
 (0)