Patchwork [bitbake-devel] utils: Add workaround for multiprocessing bug

mail settings
Submitter Richard Purdie
Date Aug. 21, 2014, 8:47 p.m.
Message ID <1408654045.1669.118.camel@ted>
Download mbox | patch
Permalink /patch/78771/
State New
Headers show


Richard Purdie - Aug. 21, 2014, 8:47 p.m.
Our usage of multitprocessing is problematic. In particular, there is a bug
in python 2.7 multiprocessing where signals are not handled until command
completion instead of immediately.

This adds a workaround into our wrapper function to deal with the issue.

Signed-off-by: Richard Purdie <>


diff --git a/bitbake/lib/bb/ b/bitbake/lib/bb/
index 781af3a..11f046a 100644
--- a/bitbake/lib/bb/
+++ b/bitbake/lib/bb/
@@ -883,5 +883,17 @@  def process_profilelog(fn):
 # Was present to work around multiprocessing pool bugs in python < 2.7.3
 def multiprocessingpool(*args, **kwargs):
+    import multiprocessing.pool
+    #import multiprocessing.util
+    #multiprocessing.util.log_to_stderr(10)
+    # Deal with a multiprocessing bug where signals to the processes would be delayed until the work
+    # completes. Putting in a timeout means the signals (like SIGINT/SIGTERM) get processed.
+    def wrapper(func):
+        def wrap(self, timeout=None):
+            return func(self, timeout=timeout if timeout is not None else 1e100)
+        return wrap
+ = wrapper(
     return multiprocessing.Pool(*args, **kwargs)