diff mbox series

[3/3] knotty, teamcity, tinfoil: Only allow one process progress bar at once

Message ID 20251011031135.2243358-3-pkj@axis.com
State New
Headers show
Series [1/3] knotty, uihelper: Remove running_pids and lastpids | expand

Commit Message

Peter Kjellerstedt Oct. 11, 2025, 3:11 a.m. UTC
In case a process progress bar (e.g., "Initialising tasks") is active
when a new one (e.g., "Checking sstate mirror object availability") is
started, then finish the first one before starting the second. Also
ignore ProcessProgress and ProcessFinished events that are not for the
currently active progress bar.

This also adds an id to BBProgress (initialized to the initial msg),
which is not affected by calls to setmessage().

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 bitbake/lib/bb/tinfoil.py     | 10 +++++-----
 bitbake/lib/bb/ui/knotty.py   | 12 +++++++-----
 bitbake/lib/bb/ui/teamcity.py | 14 +++++++++++---
 3 files changed, 23 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index e7fbcbca0a..0a8950e730 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -91,23 +91,23 @@  def wait_for(f):
                             if isinstance(event, bb.event.ProcessStarted):
                                 if self.quiet > 1:
                                     continue
+                                if parseprogress:
+                                    parseprogress,finish()
                                 parseprogress = bb.ui.knotty.new_progress(event.processname, event.total)
                                 parseprogress.start(False)
                                 continue
                             if isinstance(event, bb.event.ProcessProgress):
                                 if self.quiet > 1:
                                     continue
-                                if parseprogress:
+                                if parseprogress and parseprogress.id == event.processname:
                                     parseprogress.update(event.progress)
-                                else:
-                                    bb.warn("Got ProcessProgress event for something that never started?")
                                 continue
                             if isinstance(event, bb.event.ProcessFinished):
                                 if self.quiet > 1:
                                     continue
-                                if parseprogress:
+                                if parseprogress and parseprogress.id == event.processname:
                                     parseprogress.finish()
-                                parseprogress = None
+                                    parseprogress = None
                                 continue
                             if isinstance(event, bb.command.CommandCompleted):
                                 result = True
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 6f03bf2faa..4bcf6bd12f 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -39,6 +39,7 @@  interactive = sys.stdout.isatty()
 
 class BBProgress(progressbar.ProgressBar):
     def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None):
+        self.id = msg
         self.msg = msg
         self.extrapos = extrapos
         if not widgets:
@@ -84,6 +85,7 @@  class NonInteractiveProgress(object):
     fobj = sys.stdout
 
     def __init__(self, msg, maxval):
+        self.id = msg
         self.msg = msg
         self.maxval = maxval
         self.finished = False
@@ -886,23 +888,23 @@  def main(server, eventHandler, params, tf = TerminalFilter):
                 if params.options.quiet > 1:
                     continue
                 termfilter.clearFooter()
+                if parseprogress:
+                    parseprogress.finish()
                 parseprogress = new_progress(event.processname, event.total)
                 parseprogress.start(False)
                 continue
             if isinstance(event, bb.event.ProcessProgress):
                 if params.options.quiet > 1:
                     continue
-                if parseprogress:
+                if parseprogress and parseprogress.id == event.processname:
                     parseprogress.update(event.progress)
-                else:
-                    bb.warn("Got ProcessProgress event for someting that never started?")
                 continue
             if isinstance(event, bb.event.ProcessFinished):
                 if params.options.quiet > 1:
                     continue
-                if parseprogress:
+                if parseprogress and parseprogress.id == event.processname:
                     parseprogress.finish()
-                parseprogress = None
+                    parseprogress = None
                 continue
 
             # ignore
diff --git a/bitbake/lib/bb/ui/teamcity.py b/bitbake/lib/bb/ui/teamcity.py
index 7eeaab8d63..3177f4aaf4 100644
--- a/bitbake/lib/bb/ui/teamcity.py
+++ b/bitbake/lib/bb/ui/teamcity.py
@@ -200,6 +200,7 @@  def main(server, eventHandler, params):
         logger.error("XMLRPC Fault getting commandline: {0}".format(x))
         return 1
 
+    active_process = None
     active_process_total = None
     is_tasks_running = False
 
@@ -300,16 +301,23 @@  def main(server, eventHandler, params):
 
             if isinstance(event, bb.event.ProcessStarted):
                 if event.processname in ["Initialising tasks", "Checking sstate mirror object availability"]:
+                    if active_process:
+                        ui.progress(active_process, 100)
+                        ui.block_end()
+                    active_process = event.processname
                     active_process_total = event.total
                     ui.block_start(event.processname)
             if isinstance(event, bb.event.ProcessFinished):
                 if event.processname in ["Initialising tasks", "Checking sstate mirror object availability"]:
-                    ui.progress(event.processname, 100)
-                    ui.block_end()
+                    if active_process and active_process == event.processname:
+                        ui.progress(event.processname, 100)
+                        ui.block_end()
+                        active_process = None
             if isinstance(event, bb.event.ProcessProgress):
                 if event.processname in ["Initialising tasks",
                                          "Checking sstate mirror object availability"] and active_process_total != 0:
-                    ui.progress(event.processname, event.progress * 100 / active_process_total)
+                    if active_process and active_process == event.processname:
+                        ui.progress(event.processname, event.progress * 100 / active_process_total)
             if isinstance(event, bb.event.CacheLoadStarted):
                 ui.block_start("Loading cache")
             if isinstance(event, bb.event.CacheLoadProgress):