From 4e119e683881e2523d46531e3d33eb2625e72bc2 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Tue, 27 Nov 2012 12:23:06 +0100 Subject: [PATCH] uwsgiconfig: permit to override CPUCOUNT with environment variable CPUCOUNT=X make will force X cores instead of the autodetected ones --- uwsgiconfig.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 48ab00ea..07f8ca9d 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -33,15 +33,20 @@ if not GCC: CPP = os.environ.get('CPP', 'cpp') -CPUCOUNT = 1 try: - import multiprocessing - CPUCOUNT = multiprocessing.cpu_count() + CPUCOUNT = int(os.environ.get('CPUCOUNT', -1)) except: + CPUCOUNT = -1 + +if CPUCOUNT < 1: try: - CPUCOUNT = int(os.sysconf('SC_NPROCESSORS_ONLN')) + import multiprocessing + CPUCOUNT = multiprocessing.cpu_count() except: - pass + try: + CPUCOUNT = int(os.sysconf('SC_NPROCESSORS_ONLN')) + except: + CPUCOUNT = 1 binary_list = []