From f14c1e3e917d33ea58c5c89d109feac8fbeedd38 Mon Sep 17 00:00:00 2001 From: Jeroen Hoekx Date: Mon, 30 Apr 2012 09:47:04 +0200 Subject: [PATCH] Async: print one poll message per polling cycle. Instead of one per host per polling cycle. --- lib/ansible/callbacks.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 0f9764b294d..256ceb5586e 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -115,6 +115,7 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks): def __init__(self): # set by /usr/bin/ansible later self.options = None + self._async_notified = {} def on_failed(self, host, res): invocation = res.get('invocation','') @@ -141,7 +142,11 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks): print >>sys.stderr, "no hosts matched\n" def on_async_poll(self, host, res, jid, clock): - print " polling on %s, %s remaining"%(jid, host, clock) + if jid not in self._async_notified: + self._async_notified[jid] = clock + 1 + if self._async_notified[jid] > clock: + self._async_notified[jid] = clock + print " polling, %ss remaining"%(jid, clock) def on_async_ok(self, host, res, jid): print " finished on %s => %s"%(jid, host, utils.bigjson(res)) @@ -161,6 +166,7 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): def __init__(self, stats): self.stats = stats + self._async_notified = {} def on_unreachable(self, host, msg): print "fatal: [%s] => %s" % (host, msg) @@ -191,7 +197,11 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): print "no hosts matched or remaining\n" def on_async_poll(self, host, res, jid, clock): - print " polling on %s, %s remaining"%(jid, host, clock) + if jid not in self._async_notified: + self._async_notified[jid] = clock + 1 + if self._async_notified[jid] > clock: + self._async_notified[jid] = clock + print " polling, %ss remaining"%(jid, clock) def on_async_ok(self, host, res, jid): print " finished on %s"%(jid, host)