summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-07 11:04:31 -0500
committerAbderrahim Kitouni <a.kitouni@gmail.com>2019-04-12 14:58:11 +0000
commit5c36bca85bd8a3298c9df50c154a50f03507ab47 (patch)
tree0941e3878276037d4d1b9cfcc7d4e6edef704031
parent1147e208f40ee7a9932c6d5413e8b46a97c01f74 (diff)
downloadbuildstream-5c36bca85bd8a3298c9df50c154a50f03507ab47.tar.gz
Fix stack traces discovered with ^C forceful termination.
* utils.py:_kill_process_tree(): Ignore NoSuchProcess errors These are caused because we issue SIGTERM, and if the process has not exited after a timeout, we kill it. * _scheduler/jobs/job.py: Stop handling NoSuchProcess errors here redundantly, they are already ignored. It seems that we were ignoring it after sleeping when terminating tasks from the scheduler... but we were not ignoring it when performing the same pattern in the `Plugin.call()` -> `utils._call()` path, so we were still getting these exceptions at termination time from host tool processes launched by source plugins.
-rw-r--r--buildstream/_scheduler/jobs/job.py11
-rw-r--r--buildstream/utils.py5
2 files changed, 6 insertions, 10 deletions
diff --git a/buildstream/_scheduler/jobs/job.py b/buildstream/_scheduler/jobs/job.py
index d2f5f6536..98f5fdd5e 100644
--- a/buildstream/_scheduler/jobs/job.py
+++ b/buildstream/_scheduler/jobs/job.py
@@ -28,8 +28,6 @@ import traceback
import asyncio
import multiprocessing
-import psutil
-
# BuildStream toplevel imports
from ..._exceptions import ImplError, BstError, set_last_task_error, SkipJob
from ..._message import Message, MessageType, unconditional_messages
@@ -213,17 +211,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 992218b5e..e3e9dc8c0 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -998,6 +998,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: