mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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.
This commit is contained in:
parent
4cb814c7e1
commit
4088ad9dce
1 changed files with 10 additions and 2 deletions
|
@ -355,11 +355,19 @@ class SubprocessMixin:
|
|||
create = self.loop.subprocess_exec(asyncio.SubprocessProtocol,
|
||||
*PROGRAM_BLOCKED)
|
||||
transport, protocol = yield from create
|
||||
|
||||
kill_called = False
|
||||
def kill():
|
||||
nonlocal kill_called
|
||||
kill_called = True
|
||||
orig_kill()
|
||||
|
||||
proc = transport.get_extra_info('subprocess')
|
||||
proc.kill = mock.Mock()
|
||||
orig_kill = proc.kill
|
||||
proc.kill = kill
|
||||
returncode = transport.get_returncode()
|
||||
transport.close()
|
||||
return (returncode, proc.kill.called)
|
||||
return (returncode, kill_called)
|
||||
|
||||
# Ignore "Close running child process: kill ..." log
|
||||
with test_utils.disable_logger():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue