py3: catch ProcessLookupError instead of checking errno == ESRCH
authorManuel Jacob <me@manueljacob.de>
Tue, 31 May 2022 23:45:33 +0200
changeset 49309 d54b213c4380
parent 49308 d2adebe35635
child 49310 050dc8730858
py3: catch ProcessLookupError instead of checking errno == ESRCH
mercurial/worker.py
tests/killdaemons.py
--- 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):