Unverified Commit a9c0e0c7 authored by Neelay Shah's avatar Neelay Shah Committed by GitHub
Browse files

fix: for handling zombie process (#1801)

parent c9a60278
...@@ -140,7 +140,7 @@ class ManagedProcess: ...@@ -140,7 +140,7 @@ class ManagedProcess:
cmdline, cmdline,
) )
terminate_process_tree(ps_process.pid, self._logger) terminate_process_tree(ps_process.pid, self._logger)
except (psutil.NoSuchProcess, psutil.AccessDenied): except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
# Process may have terminated or become inaccessible during iteration # Process may have terminated or become inaccessible during iteration
pass pass
...@@ -256,21 +256,32 @@ class ManagedProcess: ...@@ -256,21 +256,32 @@ class ManagedProcess:
def _terminate_existing(self): def _terminate_existing(self):
if self.terminate_existing: if self.terminate_existing:
for proc in psutil.process_iter(["name", "cmdline"]): for proc in psutil.process_iter(["name", "cmdline"]):
if proc.name() == self._command_name or proc.name() in self.stragglers: try:
self._logger.info( if (
"Terminating Existing %s %s", proc.name(), proc.pid proc.name() == self._command_name
) or proc.name() in self.stragglers
):
terminate_process_tree(proc.pid, self._logger)
for cmdline in self.straggler_commands:
if cmdline in " ".join(proc.cmdline()):
self._logger.info( self._logger.info(
"Terminating Existing CmdLine %s %s %s", "Terminating Existing %s %s", proc.name(), proc.pid
proc.name(),
proc.pid,
proc.cmdline(),
) )
terminate_process_tree(proc.pid, self._logger) terminate_process_tree(proc.pid, self._logger)
for cmdline in self.straggler_commands:
if cmdline in " ".join(proc.cmdline()):
self._logger.info(
"Terminating Existing CmdLine %s %s %s",
proc.name(),
proc.pid,
proc.cmdline(),
)
terminate_process_tree(proc.pid, self._logger)
except (
psutil.NoSuchProcess,
psutil.AccessDenied,
psutil.ZombieProcess,
):
# Process may have terminated or become inaccessible during iteration
pass
def main(): def main():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment