From fc5b5223c76ea5d9774bec77591c7b190270bea7 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 6 May 2010 18:53:29 +0000 Subject: Correct brokertest.retry logic. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@941852 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/brokertest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'python/qpid') diff --git a/python/qpid/brokertest.py b/python/qpid/brokertest.py index e05a172ab4..f78dcf4c35 100644 --- a/python/qpid/brokertest.py +++ b/python/qpid/brokertest.py @@ -94,12 +94,12 @@ def retry(function, timeout=5, delay=.01): """Call function until it returns True or timeout expires. Double the delay for each retry. Return True if function returns true, False if timeout expires.""" - elapsed = 0 while not function(): - elapsed += delay - if elapsed > timeout: return False - delay *= 2 + if delay > timeout: delay = timeout time.sleep(delay) + timeout -= delay + if timeout <= 0: return False + delay *= 2 return True class Popen(popen2.Popen3): -- cgit v1.2.1