bpo-31019: Fix multiprocessing.Process.is_alive() (#2875) · python/cpython@2db6482 (original) (raw)

Original file line number Diff line number Diff line change
@@ -148,10 +148,16 @@ def is_alive(self):
148 148 if self is _current_process:
149 149 return True
150 150 assert self._parent_pid == os.getpid(), 'can only test a child process'
151 +
151 152 if self._popen is None:
152 153 return False
153 -self._popen.poll()
154 -return self._popen.returncode is None
154 +
155 +returncode = self._popen.poll()
156 +if returncode is None:
157 +return True
158 +else:
159 +_children.discard(self)
160 +return False
155 161
156 162 def close(self):
157 163 '''