mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #19310: asyncio: fix child processes reaping logic.
This commit is contained in:
parent
e5a3154c63
commit
5121debebf
1 changed files with 19 additions and 17 deletions
|
|
@ -167,23 +167,25 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
||||||
|
|
||||||
def _sig_chld(self):
|
def _sig_chld(self):
|
||||||
try:
|
try:
|
||||||
try:
|
# because of signal coalescing, we must keep calling waitpid() as
|
||||||
pid, status = os.waitpid(-1, os.WNOHANG)
|
# long as we're able to reap a child
|
||||||
except ChildProcessError:
|
while True:
|
||||||
return
|
try:
|
||||||
if pid == 0:
|
pid, status = os.waitpid(-1, os.WNOHANG)
|
||||||
self.call_soon(self._sig_chld)
|
except ChildProcessError:
|
||||||
return
|
break
|
||||||
elif os.WIFSIGNALED(status):
|
if pid == 0:
|
||||||
returncode = -os.WTERMSIG(status)
|
break
|
||||||
elif os.WIFEXITED(status):
|
elif os.WIFSIGNALED(status):
|
||||||
returncode = os.WEXITSTATUS(status)
|
returncode = -os.WTERMSIG(status)
|
||||||
else:
|
elif os.WIFEXITED(status):
|
||||||
self.call_soon(self._sig_chld)
|
returncode = os.WEXITSTATUS(status)
|
||||||
return
|
else:
|
||||||
transp = self._subprocesses.get(pid)
|
# shouldn't happen
|
||||||
if transp is not None:
|
continue
|
||||||
transp._process_exited(returncode)
|
transp = self._subprocesses.get(pid)
|
||||||
|
if transp is not None:
|
||||||
|
transp._process_exited(returncode)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Unknown exception in SIGCHLD handler')
|
logger.exception('Unknown exception in SIGCHLD handler')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue