From c7315a218af22893768f1a2c8db29ff74ecabb41 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 5 Mar 2020 10:33:07 +0100 Subject: 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. --- rtemstoolkit/linux.py | 16 ++-------------- 1 file 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() -- cgit v1.2.3