diff options
Diffstat (limited to 'lib/spack/spack/cmd/common/arguments.py')
-rw-r--r-- | lib/spack/spack/cmd/common/arguments.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py index b228c16071..1428b8da36 100644 --- a/lib/spack/spack/cmd/common/arguments.py +++ b/lib/spack/spack/cmd/common/arguments.py @@ -5,6 +5,7 @@ import argparse +import multiprocessing import spack.cmd import spack.config @@ -86,6 +87,7 @@ class SetParallelJobs(argparse.Action): '[expected a positive integer, got "{1}"]' raise ValueError(msg.format(option_string, jobs)) + jobs = min(jobs, multiprocessing.cpu_count()) spack.config.set('config:build_jobs', jobs, scope='command_line') setattr(namespace, 'jobs', jobs) @@ -94,7 +96,8 @@ class SetParallelJobs(argparse.Action): def default(self): # This default is coded as a property so that look-up # of this value is done only on demand - return spack.config.get('config:build_jobs') + return min(spack.config.get('config:build_jobs'), + multiprocessing.cpu_count()) @default.setter def default(self, value): |