giraffesyo / awsretry

Decorate your AWS Boto3 Calls with AWSRetry.backoff(). This will allows your calls to get around the AWS Eventual Consistency Errors.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWSRetry - Boto3 Retry/Backoff Decorator

AWSRetry is a Python Decorator that can be used to wrap boto3 function calls. This function was built out of the need to get around a couple of common issues when working with AWS API's.

  • Query API Request Rate
  • Eventual Consistency Model.

Exceptions that will get retried when encountered

  • RequestLimitExceeded
  • Unavailable
  • ServiceUnavailable
  • InternalFailure
  • InternalError
  • ^w+.NotFound

This list can be extended. (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html)

Quick Start

Install awsretry.

I will assume you know about setting up Boto3 Credentials, if not you can read the instructions here http://boto3.readthedocs.io/en/latest/guide/configuration.html

Keyword Arguments that AWSRetry.backoff accepts

  • tries = The number of times to try before giving up. Default = 10
  • delay = The initial delay between retries in seconds. Default = 3
  • backoff = backoff multiplier e.g. value of 2 will double the delay each retry. Default = 1.1
  • added_exceptions = Other exceptions to retry on, beyond the defaults. Default = list()

Examples

Write a quick function that implements AWSRetry.backoff()

Write a quick function that will overwrite the default arguments.

Development

Assuming that you have Python and virtualenv installed, set up your environment and install the required dependencies like this instead of the pip install awsretry defined above:

Running Tests

You can run the tests by using tox which implements nosetest or run them directly using nosetest.

About

Decorate your AWS Boto3 Calls with AWSRetry.backoff(). This will allows your calls to get around the AWS Eventual Consistency Errors.


Languages

Language:Python 100.0%