mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
A few tweaks to improve new forking code
This commit is contained in:
parent
89603a0509
commit
f8ff63f8c8
1 changed files with 5 additions and 2 deletions
|
@ -149,17 +149,20 @@ class StrategyBase:
|
||||||
# way to share them with the forked processes
|
# way to share them with the forked processes
|
||||||
shared_loader_obj = SharedPluginLoaderObj()
|
shared_loader_obj = SharedPluginLoaderObj()
|
||||||
|
|
||||||
|
queued = False
|
||||||
while True:
|
while True:
|
||||||
(worker_prc, main_q, rslt_q) = self._workers[self._cur_worker]
|
(worker_prc, main_q, rslt_q) = self._workers[self._cur_worker]
|
||||||
if worker_prc is None or not worker_prc.is_alive():
|
if worker_prc is None or not worker_prc.is_alive():
|
||||||
worker_prc = WorkerProcess(rslt_q, task_vars, host, task, play_context, self._loader, self._variable_manager, shared_loader_obj)
|
worker_prc = WorkerProcess(rslt_q, task_vars, host, task, play_context, self._loader, self._variable_manager, shared_loader_obj)
|
||||||
self._workers[self._cur_worker][0] = worker_prc
|
self._workers[self._cur_worker][0] = worker_prc
|
||||||
worker_prc.start()
|
worker_prc.start()
|
||||||
break
|
queued = True
|
||||||
self._cur_worker += 1
|
self._cur_worker += 1
|
||||||
if self._cur_worker >= len(self._workers):
|
if self._cur_worker >= len(self._workers):
|
||||||
self._cur_worker = 0
|
self._cur_worker = 0
|
||||||
time.sleep(0.0001)
|
time.sleep(0.0001)
|
||||||
|
if queued:
|
||||||
|
break
|
||||||
|
|
||||||
del task_vars
|
del task_vars
|
||||||
self._pending_results += 1
|
self._pending_results += 1
|
||||||
|
@ -196,7 +199,7 @@ class StrategyBase:
|
||||||
else:
|
else:
|
||||||
iterator.mark_host_failed(host)
|
iterator.mark_host_failed(host)
|
||||||
(state, tmp_task) = iterator.get_next_task_for_host(host, peek=True)
|
(state, tmp_task) = iterator.get_next_task_for_host(host, peek=True)
|
||||||
if state.run_state != PlayIterator.ITERATING_RESCUE:
|
if not state or state.run_state != PlayIterator.ITERATING_RESCUE:
|
||||||
self._tqm._failed_hosts[host.name] = True
|
self._tqm._failed_hosts[host.name] = True
|
||||||
self._tqm._stats.increment('failures', host.name)
|
self._tqm._stats.increment('failures', host.name)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue