summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-10-06 16:52:07 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-10-09 12:33:26 +0100
commit31aafe68523f4ee9cf2301929b7df11b9b2c05e8 (patch)
tree4554e5eb7b6ee50a792d0ddf052e9efe62a4f69e /bitbake
parent9489382b6a77786e5d040b4da4a654788d1e9a42 (diff)
downloadpoky-31aafe68523f4ee9cf2301929b7df11b9b2c05e8.tar.gz
bitbake: ui/knotty.py: Fix signal handling of SIGWINCH in BBProgress
Add the ability to pass default signal handler for SIGWINCH in BBProgress because with multiple instace of BBProgress the original signal handler set by TerminalFilter (sigwinch_handle) is lost. This is a fix for stack trace due to multiple async calls of ProgressBar _handle_resize (ioctl to terminal fd), see: NOTE: Executing SetScene Tasks Fatal Python error: Cannot recover from stack overflow. Current thread 0x00007f70a4793700 (most recent call first): File "/home/alimonb/repos/poky/bitbake/lib/progressbar/progressbar.py", line 183 in _handle_resize File "/home/alimonb/repos/poky/bitbake/lib/bb/ui/knotty.py", line 58 in _handle_resize File "/home/alimonb/repos/poky/bitbake/lib/bb/ui/knotty.py", line 60 in _handle_resize ... File "/home/alimonb/repos/poky/bitbake/lib/bb/ui/knotty.py", line 60 in _handle_resize ... Aborted (Bitbake rev: 812bd49cb569379ee90d5be28a4b6e60645f1e54) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/ui/knotty.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index b31a8a18e1..948f52769d 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -32,6 +32,7 @@ import fcntl
32import struct 32import struct
33import copy 33import copy
34import atexit 34import atexit
35
35from bb.ui import uihelper 36from bb.ui import uihelper
36 37
37featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS] 38featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS]
@@ -40,7 +41,7 @@ logger = logging.getLogger("BitBake")
40interactive = sys.stdout.isatty() 41interactive = sys.stdout.isatty()
41 42
42class BBProgress(progressbar.ProgressBar): 43class BBProgress(progressbar.ProgressBar):
43 def __init__(self, msg, maxval, widgets=None, extrapos=-1): 44 def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None):
44 self.msg = msg 45 self.msg = msg
45 self.extrapos = extrapos 46 self.extrapos = extrapos
46 if not widgets: 47 if not widgets:
@@ -48,10 +49,10 @@ class BBProgress(progressbar.ProgressBar):
48 progressbar.ETA()] 49 progressbar.ETA()]
49 self.extrapos = 4 50 self.extrapos = 4
50 51
51 try: 52 if resize_handler:
53 self._resize_default = resize_handler
54 else:
52 self._resize_default = signal.getsignal(signal.SIGWINCH) 55 self._resize_default = signal.getsignal(signal.SIGWINCH)
53 except:
54 self._resize_default = None
55 progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets, fd=sys.stdout) 56 progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets, fd=sys.stdout)
56 57
57 def _handle_resize(self, signum=None, frame=None): 58 def _handle_resize(self, signum=None, frame=None):
@@ -247,10 +248,10 @@ class TerminalFilter(object):
247 start_time = activetasks[t].get("starttime", None) 248 start_time = activetasks[t].get("starttime", None)
248 if not pbar or pbar.bouncing != (progress < 0): 249 if not pbar or pbar.bouncing != (progress < 0):
249 if progress < 0: 250 if progress < 0:
250 pbar = BBProgress("0: %s (pid %s) " % (activetasks[t]["title"], t), 100, widgets=[progressbar.BouncingSlider(), ''], extrapos=2) 251 pbar = BBProgress("0: %s (pid %s) " % (activetasks[t]["title"], t), 100, widgets=[progressbar.BouncingSlider(), ''], extrapos=2, resize_handler=self.sigwinch_handle)
251 pbar.bouncing = True 252 pbar.bouncing = True
252 else: 253 else:
253 pbar = BBProgress("0: %s (pid %s) " % (activetasks[t]["title"], t), 100, widgets=[progressbar.Percentage(), ' ', progressbar.Bar(), ''], extrapos=4) 254 pbar = BBProgress("0: %s (pid %s) " % (activetasks[t]["title"], t), 100, widgets=[progressbar.Percentage(), ' ', progressbar.Bar(), ''], extrapos=4, resize_handler=self.sigwinch_handle)
254 pbar.bouncing = False 255 pbar.bouncing = False
255 activetasks[t]["progressbar"] = pbar 256 activetasks[t]["progressbar"] = pbar
256 tasks.append((pbar, progress, rate, start_time)) 257 tasks.append((pbar, progress, rate, start_time))
@@ -274,7 +275,7 @@ class TerminalFilter(object):
274 maxtask = self.helper.tasknumber_total 275 maxtask = self.helper.tasknumber_total
275 if not self.main_progress or self.main_progress.maxval != maxtask: 276 if not self.main_progress or self.main_progress.maxval != maxtask:
276 widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()] 277 widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
277 self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets) 278 self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle)
278 self.main_progress.start(False) 279 self.main_progress.start(False)
279 self.main_progress.setmessage(content) 280 self.main_progress.setmessage(content)
280 progress = self.helper.tasknumber_current - 1 281 progress = self.helper.tasknumber_current - 1