]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-37380: subprocess: don't use _active on win (GH-14360) (GH-15707)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 6 Sep 2019 09:14:31 +0000 (02:14 -0700)
committerVictor Stinner <vstinner@redhat.com>
Fri, 6 Sep 2019 09:14:31 +0000 (11:14 +0200)
commit4d1abedce9422473af2ac78047e55cde73208208
tree97d44d582ded5ced53755693290f5d27375483c7
parentb8c66779c7003071f1a330428d58bbbb34c7ae12
bpo-37380: subprocess: don't use _active on win (GH-14360) (GH-15707)

As noted by @eryksun in [1] and [2], using _cleanup and _active(in
__del__) is not necessary on Windows, since:

> Unlike Unix, a process in Windows doesn't have to be waited on by
> its parent to avoid a zombie. Keeping the handle open will actually
> create a zombie until the next _cleanup() call, which may be never
> if Popen() isn't called again.

This patch simply defines `subprocess._active` as `None`, for which we already
have the proper logic in place in `subprocess.Popen.__del__`, that prevents it
from trying to append the process to the `_active`. This patch also defines
`subprocess._cleanup` as a noop for Windows.

[1] https://bugs.python.org/issue37380GH-msg346333
[2] https://bugs.python.org/issue36067GH-msg336262

Signed-off-by: Ruslan Kuprieiev <ruslan@iterative.ai>
(cherry picked from commit 042821ae3cf537e01963c9ec85d1a454d921e826)

Co-authored-by: Ruslan Kuprieiev <kupruser@gmail.com>
Lib/subprocess.py
Lib/test/test_subprocess.py
Misc/NEWS.d/next/Windows/2019-06-25-04-15-22.bpo-37380.tPxjuz.rst [new file with mode: 0644]