changeset 49303:dfdf85f37215

py3: catch ChildProcessError instead of checking errno == ECHILD
author Manuel Jacob <me@manueljacob.de>
date Tue, 31 May 2022 04:18:22 +0200
parents ee4537e365c8
children 48f1b314056b
files mercurial/commandserver.py mercurial/worker.py
diffstat 2 files changed, 5 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commandserver.py	Tue May 31 04:11:34 2022 +0200
+++ b/mercurial/commandserver.py	Tue May 31 04:18:22 2022 +0200
@@ -693,9 +693,7 @@
         while self._workerpids:
             try:
                 pid, _status = os.waitpid(-1, options)
-            except OSError as inst:
-                if inst.errno != errno.ECHILD:
-                    raise
+            except ChildProcessError:
                 # no child processes at all (reaped by other waitpid()?)
                 self._workerpids.clear()
                 return
--- a/mercurial/worker.py	Tue May 31 04:11:34 2022 +0200
+++ b/mercurial/worker.py	Tue May 31 04:18:22 2022 +0200
@@ -186,13 +186,10 @@
             p = st = 0
             try:
                 p, st = os.waitpid(pid, (0 if blocking else os.WNOHANG))
-            except OSError as e:
-                if e.errno == errno.ECHILD:
-                    # child would already be reaped, but pids yet been
-                    # updated (maybe interrupted just after waitpid)
-                    pids.discard(pid)
-                else:
-                    raise
+            except ChildProcessError:
+                # child would already be reaped, but pids yet been
+                # updated (maybe interrupted just after waitpid)
+                pids.discard(pid)
             if not p:
                 # skip subsequent steps, because child process should
                 # be still running in this case