diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py index 9754f2f9239..6f672a01eb3 100755 --- a/utils/lit/lit/main.py +++ b/utils/lit/lit/main.py @@ -111,8 +111,7 @@ def write_test_results(run, lit_config, testing_time, output_path): def main(builtinParameters = {}): # Use processes by default on Unix platforms. isWindows = platform.system() == 'Windows' - # multiprocessing is broken on various BSD Python versions: http://bugs.python.org/issue3770 - useProcessesIsDefault = (not isWindows) and ('BSD' not in platform.system()) + useProcessesIsDefault = not isWindows global options from optparse import OptionParser, OptionGroup diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py index 8642ff18927..8aaf52f1aec 100644 --- a/utils/lit/lit/run.py +++ b/utils/lit/lit/run.py @@ -209,16 +209,20 @@ class Run(object): """ # Choose the appropriate parallel execution implementation. - if jobs == 1 or not use_processes or multiprocessing is None: + if jobs != 1 and use_processes and multiprocessing: + try: + task_impl = multiprocessing.Process + queue_impl = multiprocessing.Queue + canceled_flag = multiprocessing.Value('i', 0) + consumer = MultiprocessResultsConsumer(self, display, jobs) + except ImportError: + # Workaround for BSD: http://bugs.python.org/issue3770 + consumer = None + if not consumer: task_impl = threading.Thread queue_impl = queue.Queue canceled_flag = LockedValue(0) consumer = ThreadResultsConsumer(display) - else: - task_impl = multiprocessing.Process - queue_impl = multiprocessing.Queue - canceled_flag = multiprocessing.Value('i', 0) - consumer = MultiprocessResultsConsumer(self, display, jobs) # Create the test provider. provider = TestProvider(self.tests, jobs, queue_impl, canceled_flag)