diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-03-05 10:33:07 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-03-05 10:33:07 +0100 |
commit | c7315a218af22893768f1a2c8db29ff74ecabb41 (patch) | |
tree | 87cc09c1ae9d60c51413daac3448535288601420 | |
parent | rtemstoolkit: Support more Linux distributions (diff) | |
download | rtems-tools-c7315a218af22893768f1a2c8db29ff74ecabb41.tar.bz2 |
rtemstoolkit: Use multiprocessing.cpu_count()
The previous implementation does not work on some Linux distributions,
e.g. Debian on sparc64. Use a standard function instead.
-rw-r--r-- | rtemstoolkit/linux.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/rtemstoolkit/linux.py b/rtemstoolkit/linux.py index 1b55655..21f6f97 100644 --- a/rtemstoolkit/linux.py +++ b/rtemstoolkit/linux.py @@ -33,26 +33,14 @@ # RTEMS project's spec files. # +import multiprocessing import os import platform -from rtemstoolkit import execute from rtemstoolkit import path def cpus(): - processors = '/bin/grep processor /proc/cpuinfo' - e = execute.capture_execution() - exit_code, proc, output = e.shell(processors) - ncpus = 0 - if exit_code == 0: - try: - for l in output.split('\n'): - count = l.split(':')[1].strip() - if int(count) > ncpus: - ncpus = int(count) - except: - pass - return ncpus + 1 + return multiprocessing.cpu_count() def overrides(): uname = os.uname() |