Exemplo n.º 1
0
 def __init__(self,
              call_retry_strategies=None,
              wait_strategy=None,
              context=None,
              timeout=None,
              lambda_time_out_margin=10):
     """
     Initializes retry logic instance
     :param call_retry_strategies: List of methods that examine an event raised by a boto3 method call to determine if the
     call may succeed at a later time
     :param wait_strategy: Wait strategy that returns retry wait periods
     :param context: Lambda context that is used to calculate remaining execution time
     :param timeout: Timeout for method call. This time can not exceed the remaining time if a method is called
     within the context of a lambda function.
     :param lambda_time_out_margin: If called within the context of a Lambda function this time should at least be 
     remaining before making a retry. This is to allow possible cleanup and logging actions in the remaining time
     """
     self.default_strategies = [
         self.api_throttled, self.service_not_available
     ]
     self._call_retry_strategies = call_retry_strategies if call_retry_strategies else self.default_strategies
     self._wait_strategy = wait_strategy if wait_strategy else boto_retry.ConstantWaitStrategy(
     )
     self._timeout = timeout
     self._context = context
     self._lambda_time_out_margin = lambda_time_out_margin
Exemplo n.º 2
0
    def __init__(self, call_retry_strategies=None, logger=None, wait_strategy=None, context=None, timeout=300,
                 lambda_time_out_margin=20):
        self.default_strategies = [
            self.api_throttled,
            self.server_error,
            self.read_timeout,
            self.reset_by_peer
        ]

        self._call_retry_strategies = call_retry_strategies if call_retry_strategies else self.default_strategies
        self._wait_strategy = wait_strategy if wait_strategy else boto_retry.ConstantWaitStrategy()
        self._timeout = timeout
        self.context = context
        self.logger = logger
        self._lambda_time_out_margin = lambda_time_out_margin