diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-02-27 15:11:18 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2011-03-03 07:16:53 -0700 |
commit | 0d732b3b546ee818350cd2d64b120decb76c36e9 (patch) | |
tree | 79022e80ea8888c44a484bd3ac82358edda606d5 /lib/bb/server/process.py | |
parent | 898f557cbd443cdeff137fd926aac06f2aaee6c4 (diff) | |
download | bitbake-0d732b3b546ee818350cd2d64b120decb76c36e9.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>
Diffstat (limited to 'lib/bb/server/process.py')
-rw-r--r-- | lib/bb/server/process.py | 55 |
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 |