From 0abeff45115689cd8e1262c8c666c9263977c499 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 4 Nov 2015 12:47:10 -0500 Subject: [PATCH] better limiting of forks to lowest actual restriction --- lib/ansible/executor/task_queue_manager.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index f3d278e639..c1cc517876 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -93,10 +93,8 @@ class TaskQueueManager: self._connection_lockfile = tempfile.TemporaryFile() # Treat "forks" config parameter as max value. Only create number of workers - # equal to number of hosts in inventory if less than max value. - num_workers = self._options.forks - if self._options.forks > len(self._inventory.list_hosts()): - num_workers = len(self._inventory.list_hosts()) + # equal to number of hosts in inventory if less than max value or serial batch. + num_workers = min(self._options.forks, self._options.serial, len(self._inventory.list_hosts())) self._workers = [] for i in range(num_workers):