This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/one-cache-size-job-2
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit fa20374fb8ba3af5c01b06254909a33e27cea643
Author: Tristan Van Berkom <[email protected]>
AuthorDate: Mon Jan 7 11:04:31 2019 -0500

    utils.py: Fix stack traces when killing already dead processes
    
    Handle NoSuchProcess errors transparently inside the function, instead
    of only from outside of it where Job uses it.
---
 buildstream/_scheduler/jobs/job.py | 9 +--------
 buildstream/utils.py               | 5 +++++
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/buildstream/_scheduler/jobs/job.py 
b/buildstream/_scheduler/jobs/job.py
index 60ae0d0..3ab7bfa 100644
--- a/buildstream/_scheduler/jobs/job.py
+++ b/buildstream/_scheduler/jobs/job.py
@@ -215,17 +215,10 @@ class Job():
     # Forcefully kill the process, and any children it might have.
     #
     def kill(self):
-
         # Force kill
         self.message(MessageType.WARN,
                      "{} did not terminate gracefully, 
killing".format(self.action_name))
-
-        try:
-            utils._kill_process_tree(self._process.pid)
-        # This can happen if the process died of its own accord before
-        # we try to kill it
-        except psutil.NoSuchProcess:
-            return
+        utils._kill_process_tree(self._process.pid)
 
     # suspend()
     #
diff --git a/buildstream/utils.py b/buildstream/utils.py
index a460031..4943336 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -1050,6 +1050,11 @@ def _kill_process_tree(pid):
             # Ignore this error, it can happen with
             # some setuid bwrap processes.
             pass
+        except psutil.NoSuchProcess:
+            # It is certain that this has already been sent
+            # SIGTERM, so there is a window where the process
+            # could have exited already.
+            pass
 
     # Bloody Murder
     for child in children:

Reply via email to