diff --git a/osism/commands/worker.py b/osism/commands/worker.py index 88cac175..33a8741a 100644 --- a/osism/commands/worker.py +++ b/osism/commands/worker.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 +import multiprocessing import subprocess from cliff.command import Command @@ -7,11 +8,16 @@ class Run(Command): def get_parser(self, prog_name): + if multiprocessing.cpu_count() <= 8: + number_of_workers_default = multiprocessing.cpu_count() + else: + number_of_workers_default = 8 + parser = super(Run, self).get_parser(prog_name) parser.add_argument( "--number-of-workers", "-n", - default=16, + default=number_of_workers_default, type=int, help="Number of workers", ) diff --git a/releasenotes/notes/number-of-workers-f55a3422c0b976cc.yaml b/releasenotes/notes/number-of-workers-f55a3422c0b976cc.yaml index cac5b4f2..0147fc01 100644 --- a/releasenotes/notes/number-of-workers-f55a3422c0b976cc.yaml +++ b/releasenotes/notes/number-of-workers-f55a3422c0b976cc.yaml @@ -3,4 +3,5 @@ features: - | With the new parameter `--number-of-workers` for the worker command, it is now possible to increase the number of workers that can be used - simultaneously. The value is set to 16 by default. + simultaneously. The value is set to the number of usable CPUs by default. + If the number of usable CPUs is higher than 8, the default value is 8.