From 13750f68eed8105e6cf8e50546680023f22d6fd3 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 12 Nov 2015 14:40:56 -0500 Subject: [PATCH] Reduce spinning while waiting on queues --- lib/ansible/executor/process/result.py | 4 ++-- lib/ansible/plugins/strategy/__init__.py | 2 +- lib/ansible/plugins/strategy/linear.py | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/ansible/executor/process/result.py b/lib/ansible/executor/process/result.py index fe5d0293c47..b5f1929d956 100644 --- a/lib/ansible/executor/process/result.py +++ b/lib/ansible/executor/process/result.py @@ -73,11 +73,11 @@ class ResultProcess(multiprocessing.Process): try: if not rslt_q.empty(): debug("worker %d has data to read" % self._cur_worker) - result = rslt_q.get() + result = rslt_q.get(block=False) debug("got a result from worker %d: %s" % (self._cur_worker, result)) break except queue.Empty: - pass + time.sleep(0.01) if self._cur_worker == starting_point: break diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index db816b137e9..3cdec5b573c 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -311,7 +311,7 @@ class StrategyBase: else: raise AnsibleError("unknown result message received: %s" % result[0]) except Queue.Empty: - pass + time.sleep(0.01) return ret_results diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index 56824689c61..65240ef8fa2 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -239,9 +239,6 @@ class StrategyModule(StrategyBase): self._blocked_hosts[host.get_name()] = True self._queue_task(host, task, task_vars, play_context) - results = self._process_pending_results(iterator) - host_results.extend(results) - # if we're bypassing the host loop, break out now if run_once: break