From 0285986f521eefe609469d62b364cc79e36acbdf Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Fri, 3 Sep 2021 10:41:43 +0200 Subject: [PATCH] Handle missing os.sysconf more gracefully os.sysconf is not available on all platforms (like Windows) but it is used to retrieve the number of online processors. If missing, assume one processor (building on such a platform will most likely not work, though). Fixes: #948 ("Windows compatibility") (at least it improves the Windows support a bit) --- osc/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osc/conf.py b/osc/conf.py index b1c3331f64..a4731c3c84 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -87,11 +87,11 @@ def _get_processors(): """ get number of processors (online) based on - SC_NPROCESSORS_ONLN (returns 1 if config name does not exist). + SC_NPROCESSORS_ONLN (returns 1 if config name/os.sysconf does not exist). """ try: return os.sysconf('SC_NPROCESSORS_ONLN') - except ValueError as e: + except (AttributeError, ValueError): return 1