Skip to contentSkip to conversation

scripts/autobuild-run: make multiprocessing target picklable

PATCH New James Hilliard 1 participant 1 message May 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/autobuild-run: make multiprocessing target picklable

Python 3.14 changed the default POSIX multiprocessing start method from fork to forkserver. With forkserver, the Process target and its arguments must be picklable.

autobuild-run passes builder.run_instance as the process target after Builder.__init__() has opened self.log. This makes multiprocessing serialize the Builder instance, including the TextIOWrapper log file, and fails before the worker starts.

Use a module-level helper as the process target and pass only Builder constructor arguments to it. The child constructs Builder itself, so the log file is opened after process startup and is not serialized.

---
 scripts/autobuild-run | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
scripts/autobuild-run +9 -2
index c375f7b..54b52b8 100755
@@ -730,6 +730,12 @@ class Builder:
             except URLError:
                 sleep(30)
 
+
+def run_builder_instance(**kwargs):
+    builder = Builder(**kwargs)
+    builder.run_instance()
+
+
 class Formatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
     pass
 
@@ -866,7 +872,7 @@ def main():
     buildpid = multiprocessing.Array('i', int(args.ninstances))
     processes = []
     for i in range(0, int(args.ninstances)):
-        builder = Builder(
+        builder_kwargs = dict(
             instance = i,
             njobs = args.njobs,
             sysinfo = sysinfo,
@@ -882,7 +888,8 @@ def main():
             buildpid = buildpid,
             debug = args.debug,
             hung_build_timeout = args.hung_build_timeout)
-        p = multiprocessing.Process(target=builder.run_instance)
+        p = multiprocessing.Process(target=run_builder_instance,
+                                    kwargs=builder_kwargs)
         p.start()
         processes.append(p)
 
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot