[Concept,29/29] buildman: Extract thread setup from __init__() in builder.py

Message ID 20260106220403.2915630-30-sjg@u-boot.org
State New
Headers
Series buildman: Clean up builder.py |

Commit Message

Simon Glass Jan. 6, 2026, 10:03 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move the thread setup code into _setup_threads() to improve readability
and reduce the complexity of __init__().

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 tools/buildman/builder.py | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
  

Patch

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 0d6e7d1732c..d92748b01e9 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -445,6 +445,26 @@  class Builder:
         self._base_config = None
         self._base_environment = None
 
+        self._setup_threads(mrproper, per_board_out_dir, test_thread_exceptions)
+
+        ignore_lines = ['(make.*Waiting for unfinished)',
+                        '(Segmentation fault)']
+        self.re_make_err = re.compile('|'.join(ignore_lines))
+
+        # Handle existing graceful with SIGINT / Ctrl-C
+        signal.signal(signal.SIGINT, self.signal_handler)
+
+    def _setup_threads(self, mrproper, per_board_out_dir,
+                       test_thread_exceptions):
+        """Set up builder threads
+
+        Args:
+            mrproper (bool): True to run 'make mrproper' before building
+            per_board_out_dir (bool): True to use a separate output directory
+                per board
+            test_thread_exceptions (bool): True to make threads raise an
+                exception instead of reporting their result (for tests)
+        """
         if self.num_threads:
             self._single_builder = None
             self.queue = queue.Queue()
@@ -465,9 +485,6 @@  class Builder:
             self._single_builder = builderthread.BuilderThread(
                 self, -1, mrproper, per_board_out_dir)
 
-        # Handle existing graceful with SIGINT / Ctrl-C
-        signal.signal(signal.SIGINT, self.signal_handler)
-
     def __del__(self):
         """Get rid of all threads created by the builder"""
         self.threads.clear()