From: Chris Larson Date: Sun, 27 Feb 2011 22:11:18 +0000 (-0700) Subject: server: use local fixed _bootstrap when appropriate X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d732b3b546ee818350cd2d64b120decb76c36e9;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git 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 --- diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py index 26f72b02663..5d7f8aa9deb 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