summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-02-27 15:11:18 -0700
committerChris Larson <chris_larson@mentor.com>2011-03-11 07:25:33 -0700
commit8885b2597e76daf13bdb10cb4351283161c8aff3 (patch)
tree4356e7b0fdaab9cb342b894c77dc0c46f309ab05
parent2e667ba62e3eb06d503acbac71b4e4d1fad7d92b (diff)
downloadbitbake-8885b2597e76daf13bdb10cb4351283161c8aff3.tar.gz
server: use local fixed _bootstrap when appropriate
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>
-rw-r--r--lib/bb/server/process.py55
1 files changed, 52 insertions, 3 deletions
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 26f72b026..5d7f8aa9d 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -20,14 +20,17 @@
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