parameters: (self, cb, retry_on=None, wait_plan=None)
docstring: Retry a function.
      Params:
        cb: The function to retry.
        retry_on: A callback that takes the result of the function and returns
                  True if the function should be retried. A function throwing an
                  exception is always retried.
        wait_plan: A list of waiting delays between retries in seconds. The
                   maximum number of retries is len(wait_plan).
docstring_summary: Retry a function.
      Params:
        cb: The function to retry.
        retry_on: A callback that takes the result of the function and returns
                  True if the function should be retried. A function throwing an
                  exception is always retried.
        wait_plan: A list of waiting delays between retries in seconds. The
                   maximum number of retries is len(wait_plan).
docstring_tokens: Retry a function . Params : cb : The function to retry . retry_on : A callback that takes the result of the function and returns True if the function should be retried . A function throwing an exception is always retried . wait_plan : A list of waiting delays between retries in seconds . The maximum number of retries is len ( wait_plan ) .
function: def Retry(self, cb, retry_on=None, wait_plan=None):
      """ Retry a function.
      Params:
        cb: The function to retry.
        retry_on: A callback that takes the result of the function and returns
                  True if the function should be retried. A function throwing an
                  exception is always retried.
        wait_plan: A list of waiting delays between retries in seconds. The
                   maximum number of retries is len(wait_plan).
      """
      retry_on = retry_on or (lambda x: False)
      wait_plan = list(wait_plan or [])
      wait_plan.reverse()
      while True:
        got_exception = False
        try:
          result = cb()
        except NoRetryException as e:
          raise e
        except Exception as e:
          got_exception = e
        if got_exception or retry_on(result):
          if not wait_plan:  # pragma: no cover
            raise Exception("Retried too often. Giving up. Reason: %s" %
                            str(got_exception))
          wait_time = wait_plan.pop()
          print("Waiting for %f seconds." % wait_time)
          self._side_effect_handler.Sleep(wait_time)
          print("Retrying...")
        else:
          return result
function_tokens: def Retry ( self , cb , retry_on = None , wait_plan = None ) : retry_on = retry_on or ( lambda x : False ) wait_plan = list ( wait_plan or [ ] ) wait_plan . reverse ( ) while True : got_exception = False try : result = cb ( ) except NoRetryException as e : raise e except Exception as e : got_exception = e if got_exception or retry_on ( result ) : if not wait_plan : # pragma: no cover raise Exception ( "Retried too often. Giving up. Reason: %s" % str ( got_exception ) ) wait_time = wait_plan . pop ( ) print ( "Waiting for %f seconds." % wait_time ) self . _side_effect_handler . Sleep ( wait_time ) print ( "Retrying..." ) else : return result