Commit 2db64823 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-31019: Fix multiprocessing.Process.is_alive() (#2875)

multiprocessing.Process.is_alive() now removes the process from the
_children set if the process completed.

The change prevents leaking "dangling" processes.
parent 627d2c8e
......@@ -148,10 +148,16 @@ class BaseProcess(object):
if self is _current_process:
return True
assert self._parent_pid == os.getpid(), 'can only test a child process'
if self._popen is None:
return False
self._popen.poll()
return self._popen.returncode is None
returncode = self._popen.poll()
if returncode is None:
return True
else:
_children.discard(self)
return False
def close(self):
'''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment