diff mbox

[U-Boot,10/13] buildman: Allow builds to terminate cleanly

Message ID 1474238918-1797-11-git-send-email-sjg@chromium.org
State Accepted
Commit d436e38189a26227274a3014d3d838eb3f183488
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Sept. 18, 2016, 10:48 p.m. UTC
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 <sjg@chromium.org>
---

 tools/buildman/builder.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Tom Rini Sept. 19, 2016, 7:16 p.m. UTC | #1
On Sun, Sep 18, 2016 at 04:48:35PM -0600, Simon Glass wrote:

> 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 <sjg@chromium.org>

Yay for fixing this, killing off the running make's when I have a bad
test build going is one of the minor pitas in my workflow :)
Simon Glass Oct. 2, 2016, 12:29 a.m. UTC | #2
Hi Tom,

On 19 September 2016 at 13:16, Tom Rini <trini@konsulko.com> wrote:
> On Sun, Sep 18, 2016 at 04:48:35PM -0600, Simon Glass wrote:
>
>> 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 <sjg@chromium.org>
>
> Yay for fixing this, killing off the running make's when I have a bad
> test build going is one of the minor pitas in my workflow :)

Yes, me too.

Applied to u-boot-dm.
diff mbox

Patch

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()