changeset 49309:d54b213c4380

py3: catch ProcessLookupError instead of checking errno == ESRCH
author Manuel Jacob <me@manueljacob.de>
date Tue, 31 May 2022 23:45:33 +0200
parents d2adebe35635
children 050dc8730858
files mercurial/worker.py tests/killdaemons.py
diffstat 2 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/worker.py	Tue May 31 23:41:15 2022 +0200
+++ b/mercurial/worker.py	Tue May 31 23:45:33 2022 +0200
@@ -6,7 +6,6 @@
 # GNU General Public License version 2 or any later version.
 
 
-import errno
 import os
 import pickle
 import selectors
@@ -177,9 +176,8 @@
         for p in pids:
             try:
                 os.kill(p, signal.SIGTERM)
-            except OSError as err:
-                if err.errno != errno.ESRCH:
-                    raise
+            except ProcessLookupError:
+                pass
 
     def waitforworkers(blocking=True):
         for pid in pids.copy():
--- a/tests/killdaemons.py	Tue May 31 23:41:15 2022 +0200
+++ b/tests/killdaemons.py	Tue May 31 23:45:33 2022 +0200
@@ -1,6 +1,5 @@
 #!/usr/bin/env python3
 
-import errno
 import os
 import signal
 import sys
@@ -93,9 +92,8 @@
                 os.kill(pid, 0)
             logfn('# Daemon process %d is stuck - really killing it' % pid)
             os.kill(pid, signal.SIGKILL)
-        except OSError as err:
-            if err.errno != errno.ESRCH:
-                raise
+        except ProcessLookupError:
+            pass
 
 
 def killdaemons(pidfile, tryhard=True, remove=False, logfn=None):