def RetryWithBackoff(callable_func, retry_notify_func, initial_delay=1, backoff_factor=2, max_delay=60, max_tries=20):
 delay = initial_delay
 num_tries = 0
 while True:
  (done, opaque_value) = callable_func()
  num_tries += 1
  if done:
   return (True, opaque_value)
  if (num_tries >= max_tries):
   return (False, opaque_value)
  retry_notify_func(opaque_value, delay)
  time.sleep(delay)
  delay = min((delay * backoff_factor), max_delay)

def RetryWithBackoff ( callable_func , retry_notify_func , initial_delay = 1 , backoff_factor = 2 , max_delay = 60 , max_tries = 20 ) : delay = initial_delay num_tries = 0 while True : ( done , opaque_value ) = callable_func ( ) num_tries += 1 if done : return ( True , opaque_value ) if ( num_tries >= max_tries ) : return ( False , opaque_value ) retry_notify_func ( opaque_value , delay ) time . sleep ( delay ) delay = min ( ( delay * backoff_factor ) , max_delay )
calls a function multiple times .