]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
server: use local fixed _bootstrap when appropriate
authorChris Larson <chris_larson@mentor.com>
Sun, 27 Feb 2011 22:11:18 +0000 (15:11 -0700)
committerChris Larson <chris_larson@mentor.com>
Thu, 3 Mar 2011 14:16:53 +0000 (07:16 -0700)
When running on python versions 2.6.0 through 2.6.2, we use a local copy
of the python 2.6.6 _bootstrap method of Process, to ensure that we have
the fix for http://bugs.python.org/issue5313. This avoids the "hang" of
the bitbake process at 0% progress during the parsing on older distros
like Fedora 12.

Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/server/process.py

index 26f72b026632f9dfffc45002d73889a0fd7a85ab..5d7f8aa9deb9718ba8c9a19c80af5e47c0fa586b 100644 (file)
     This module implements a multiprocessing.Process based server for bitbake.
 """
 
+import bb
+import bb.event
+import itertools
 import logging
+import multiprocessing
+import os
 import signal
 import sys
 import time
-import bb
-import bb.event
-from multiprocessing import Process, Event
 from bb.cooker import BBCooker
+from multiprocessing import Event, Process, util
 
 logger = logging.getLogger('BitBake')
 
@@ -170,3 +173,49 @@ class ProcessServer(Process):
 
     def stop(self):
         self.keep_running.clear()
+
+    def bootstrap_2_6_6(self):
+        """Pulled from python 2.6.6. Needed to ensure we have the fix from
+        http://bugs.python.org/issue5313 when running on python version 2.6.2
+        or lower."""
+
+        try:
+            self._children = set()
+            self._counter = itertools.count(1)
+            try:
+                sys.stdin.close()
+                sys.stdin = open(os.devnull)
+            except (OSError, ValueError):
+                pass
+            multiprocessing._current_process = self
+            util._finalizer_registry.clear()
+            util._run_after_forkers()
+            util.info('child process calling self.run()')
+            try:
+                self.run()
+                exitcode = 0
+            finally:
+                util._exit_function()
+        except SystemExit, e:
+            if not e.args:
+                exitcode = 1
+            elif type(e.args[0]) is int:
+                exitcode = e.args[0]
+            else:
+                sys.stderr.write(e.args[0] + '\n')
+                sys.stderr.flush()
+                exitcode = 1
+        except:
+            exitcode = 1
+            import traceback
+            sys.stderr.write('Process %s:\n' % self.name)
+            sys.stderr.flush()
+            traceback.print_exc()
+
+        util.info('process exiting with exitcode %d' % exitcode)
+        return exitcode
+
+    # Python versions 2.6.0 through 2.6.2 suffer from a multiprocessing bug
+    # which can result in a bitbake server hang during the parsing process
+    if (2, 6, 0) <= sys.version_info < (2, 6, 3):
+        _bootstrap = bootstrap_2_6_6