def _retry_exception_async(reactor, f, steps=((0.1,) * 10)):
 saved_failure = [None]
 saved_result = [None]
 def handle_success(result):
  saved_result[0] = result
  return True
 def handle_failure(failure):
  Message.log(message_type=u'flocker:provision:libcloud:retry_exception:got_exception')
  write_failure(failure)
  saved_failure[0] = failure
  return False
 def make_call():
  d = maybeDeferred(f)
  d = DeferredContext(d)
  d.addCallbacks(handle_success, errback=handle_failure)
  return d.result
 action = start_action(action_type=u'flocker:provision:libcloud:retry_exception', function=function_serializer(f))
 with action.context():
  d = loop_until(reactor, make_call, steps)
  d = DeferredContext(d)
  d.addCallbacks((lambda _: saved_result[0]), errback=(lambda _: saved_failure[0]))
  return d.addActionFinish()

def _retry_exception_async ( reactor , f , steps = ( ( 0.1 , ) * 10 ) ) : saved_failure = [ None ] saved_result = [ None ] def handle_success ( result ) : saved_result [ 0 ] = result return True def handle_failure ( failure ) : Message . log ( message_type = u'flocker:provision:libcloud:retry_exception:got_exception' ) write_failure ( failure ) saved_failure [ 0 ] = failure return False def make_call ( ) : d = maybeDeferred ( f ) d = DeferredContext ( d ) d . addCallbacks ( handle_success , errback = handle_failure ) return d . result action = start_action ( action_type = u'flocker:provision:libcloud:retry_exception' , function = function_serializer ( f ) ) with action . context ( ) : d = loop_until ( reactor , make_call , steps ) d = DeferredContext ( d ) d . addCallbacks ( ( lambda _ : saved_result [ 0 ] ) , errback = ( lambda _ : saved_failure [ 0 ] ) ) return d . addActionFinish ( )
retry a function if it raises an exception .