From ed33e64c71e6e1974f988f6ff2df1ed0957ac9ad Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 22 Nov 2016 22:39:26 +0200 Subject: [PATCH] Guard against cpu_count failing. --- run_project_tests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/run_project_tests.py b/run_project_tests.py index dcc600642..6f4d0a3c5 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -380,7 +380,14 @@ def run_tests(extra_args): build_time = 0 test_time = 0 - executor = conc.ProcessPoolExecutor(max_workers=multiprocessing.cpu_count()) + try: + # This fails in some CI environments for unknown reasons. + num_workers = multiprocessing.cpu_count() + except Exception as e: + print('Could not determine number of CPUs due to the following reason:' + str(e)) + print('Defaulting to using only one process') + num_workers = 1 + executor = conc.ProcessPoolExecutor(max_workers=num_workers) for name, test_cases, skipped in all_tests: current_suite = ET.SubElement(junit_root, 'testsuite', {'name' : name, 'tests' : str(len(test_cases))})