From cb873084d0a29db4de571c01041f64ad390e1a2f Mon Sep 17 00:00:00 2001 From: Shane Wang Date: Thu, 23 Feb 2012 21:47:19 +0800 Subject: command.py: add new API to get the cpu count on the server Add a new API in command.py to get the cpu count in order to set the appropriate default BB_NUMBER_THREADS and PARALLEL_MAKE variables. (Bitbake rev: 335047b2e440e65713e88fabb24b47a9c82f939b) Signed-off-by: Shane Wang Signed-off-by: Richard Purdie --- bitbake/lib/bb/command.py | 6 ++++++ bitbake/lib/bb/utils.py | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'bitbake') diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index 2a3a3afaca..4e9e8d657e 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py @@ -173,6 +173,12 @@ class CommandsSync: """ command.cooker.reset() + def getCpuCount(self, command, params): + """ + Get the CPU count on the bitbake server + """ + return bb.utils.cpu_count() + class CommandsAsync: """ diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index a26635a19a..d7cefb245f 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -25,6 +25,7 @@ import errno import logging import bb import bb.msg +import multiprocessing from commands import getstatusoutput from contextlib import contextmanager @@ -862,3 +863,6 @@ def contains(variable, checkvalues, truevalue, falsevalue, d): if checkvalues.issubset(val): return truevalue return falsevalue + +def cpu_count(): + return multiprocessing.cpu_count() -- cgit v1.2.3-54-g00ecf