mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
treat forks config parameter as max value instead of always creating that number of workers
This commit is contained in:
parent
38cc0705c6
commit
3289670a04
1 changed files with 7 additions and 2 deletions
|
@ -92,8 +92,14 @@ class TaskQueueManager:
|
||||||
# plugins for inter-process locking.
|
# plugins for inter-process locking.
|
||||||
self._connection_lockfile = tempfile.TemporaryFile()
|
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())
|
||||||
|
|
||||||
self._workers = []
|
self._workers = []
|
||||||
for i in range(self._options.forks):
|
for i in range(num_workers):
|
||||||
main_q = multiprocessing.Queue()
|
main_q = multiprocessing.Queue()
|
||||||
rslt_q = multiprocessing.Queue()
|
rslt_q = multiprocessing.Queue()
|
||||||
|
|
||||||
|
@ -266,4 +272,3 @@ class TaskQueueManager:
|
||||||
method(*args, **kwargs)
|
method(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._display.warning('Error when using %s: %s' % (method, str(e)))
|
self._display.warning('Error when using %s: %s' % (method, str(e)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue