[rtems-tools commit] rtemstoolkit: Use multiprocessing.cpu_count()

Sebastian Huber sebh at rtems.org
Thu Mar 5 09:58:18 UTC 2020


Module:    rtems-tools
Branch:    master
Commit:    c7315a218af22893768f1a2c8db29ff74ecabb41
Changeset: http://git.rtems.org/rtems-tools/commit/?id=c7315a218af22893768f1a2c8db29ff74ecabb41

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Mar  5 10:33:07 2020 +0100

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



More information about the vc mailing list