def retry_effect_with_timeout(effect, timeout, retry_wait=timedelta(seconds=1), backoff=True, time=time.time):
 class State(object, ):
  end_time = None
  wait_time = None
 def should_retry(exc_info):
  if (State.end_time is None):
   State.end_time = (time() + timeout)
  if (time() >= State.end_time):
   return Effect(Constant(False))
  else:
   retry_delay = State.wait_time.total_seconds()
   effect = Effect(Delay(retry_delay)).on(success=(lambda x: Effect(Constant(True))))
   if backoff:
    State.wait_time *= 2
   return effect
 State.wait_time = retry_wait
 return retry(effect, should_retry)

def retry_effect_with_timeout ( effect , timeout , retry_wait = timedelta ( seconds = 1 ) , backoff = True , time = time . time ) : class State ( object , ) : end_time = None wait_time = None def should_retry ( exc_info ) : if ( State . end_time is None ) : State . end_time = ( time ( ) + timeout ) if ( time ( ) >= State . end_time ) : return Effect ( Constant ( False ) ) else : retry_delay = State . wait_time . total_seconds ( ) effect = Effect ( Delay ( retry_delay ) ) . on ( success = ( lambda x : Effect ( Constant ( True ) ) ) ) if backoff : State . wait_time *= 2 return effect State . wait_time = retry_wait return retry ( effect , should_retry )
if effect fails .