[PATCH 2/2] rtemstoolkit: Use multiprocessing.cpu_count()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Mar 5 09:35:05 UTC 2020


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()
-- 
2.16.4



More information about the devel mailing list