Allow to specify how log to sleep between attempts in wait_until

This commit is contained in:
Alexander Block 2018-11-15 09:44:37 +01:00
parent 3c99d9e358
commit 91af72b18f

View File

@ -1226,7 +1226,7 @@ class msg_reject(object):
% (self.message, self.code, self.reason, self.data)
# Helper function
def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf')):
def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), sleep=0.05):
attempt = 0
elapsed = 0
@ -1235,8 +1235,8 @@ def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf')):
if predicate():
return True
attempt += 1
elapsed += 0.05
time.sleep(0.05)
elapsed += sleep
time.sleep(sleep)
return False