summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-07 11:04:31 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-07 11:47:01 -0500
commit891fcb0e3a68bc4df07b9bb2b8b664d65432bc37 (patch)
treec2fdabb646d5f82c67aa1729b5cc45d5869d9310
parent7dfb85b35a71c239f592e3aed50eddeddcd10406 (diff)
downloadbuildstream-tristan/keyboard-interrupt-stack-trace.tar.gz
Fix stack traces discovered with ^C forceful termination.tristan/keyboard-interrupt-stack-trace
* 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 60ae0d001..a36483b0c 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
@@ -215,17 +213,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 a4600319b..494333680 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: