1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

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)
This commit is contained in:
Marcus Huewe 2021-09-03 10:41:43 +02:00
parent a7bdd67e92
commit 0285986f52

View File

@ -87,11 +87,11 @@ except:
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