Change the number of request retries in boto3

DG812 picture DG812 · Nov 30, 2015 · Viewed 15.9k times · Source

In boto3 or botocore, how do I do the equivalent of setting the number of request retries?

e.g. in boto2

from boto import config
config.set('Boto', 'num_retries', '20')

How do I do this in boto3? I've tried

conn._session.set_config_variable("num_retries", "20")

but when I then get_config_variable("num_retries"), None is returned.

Answer

Marty picture Marty · Feb 1, 2018

You should now be able to do this, at least for ec2 and perhaps other clients as well:

from botocore.config import Config

config = Config(
    retries = dict(
        max_attempts = 10
    )
)

ec2 = boto3.client('ec2', config=config)