def retry_over_time(fun, catch, args=[], kwargs={}, errback=None, max_retries=None, interval_start=2, interval_step=2, interval_max=30, callback=None):
 retries = 0
 interval_range = fxrange(interval_start, (interval_max + interval_start), interval_step, repeatlast=True)
 for retries in count():
  try:
   return fun(*args, **kwargs)
  except catch as exc:
   if (max_retries and (retries >= max_retries)):
    raise
   if callback:
    callback()
   tts = float((errback(exc, interval_range, retries) if errback else next(interval_range)))
   if tts:
    for _ in range(int(tts)):
     if callback:
      callback()
     sleep(1.0)
    sleep(abs((int(tts) - tts)))

def retry_over_time ( fun , catch , args = [ ] , kwargs = { } , errback = None , max_retries = None , interval_start = 2 , interval_step = 2 , interval_max = 30 , callback = None ) : retries = 0 interval_range = fxrange ( interval_start , ( interval_max + interval_start ) , interval_step , repeatlast = True ) for retries in count ( ) : try : return fun ( * args , ** kwargs ) except catch as exc : if ( max_retries and ( retries >= max_retries ) ) : raise if callback : callback ( ) tts = float ( ( errback ( exc , interval_range , retries ) if errback else next ( interval_range ) ) ) if tts : for _ in range ( int ( tts ) ) : if callback : callback ( ) sleep ( 1.0 ) sleep ( abs ( ( int ( tts ) - tts ) ) )
retry the function over and over until max retries is exceeded .