From: Simon Glass Date: Sun, 18 Sep 2016 16:48:35 -0600 Subject: [U-Boot] [PATCH 10/13] buildman: Allow builds to terminate cleanly In-Reply-To: <1474238918-1797-1-git-send-email-sjg@chromium.org> References: <1474238918-1797-1-git-send-email-sjg@chromium.org> Message-ID: <1474238918-1797-11-git-send-email-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de It is annoying that buildman does not respond cleanly to Ctrl-C or SIGINT, particularly on machines with lots of CPUS. Unfortunately queue.join() blocks the main thread and does not allow it to see the signal. Use a separate thread instead, Signed-off-by: Simon Glass --- tools/buildman/builder.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index d4ea13e..e774c2d 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -14,6 +14,7 @@ import Queue import shutil import string import sys +import threading import time import builderthread @@ -1456,8 +1457,11 @@ class Builder: job.step = self._step self.queue.put(job) - # Wait until all jobs are started - self.queue.join() + term = threading.Thread(target=self.queue.join) + term.setDaemon(True) + term.start() + while term.isAlive(): + term.join(100) # Wait until we have processed all output self.out_queue.join() -- 2.8.0.rc3.226.g39d4020