Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the number of request retries in boto3

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.

like image 530
DG812 Avatar asked Nov 30 '15 16:11

DG812


People also ask

What is adaptive retry strategy?

Adaptive retry mode is an experimental retry mode that includes all the features of standard mode. In addition to the standard mode features, adaptive mode also introduces client-side rate limiting through the use of a token bucket and rate-limit variables that are dynamically updated with each retry attempt.

Does Boto3 automatically refresh credentials?

When you specify a profile that has an IAM role configuration, Boto3 will make an AssumeRole call to retrieve temporary credentials. Subsequent Boto3 API calls will use the cached temporary credentials until they expire, in which case Boto3 will then automatically refresh the credentials.

Is Boto3 session thread safe?

boto3. client function is not thread-safe. It can fail when called from multiple threads · Issue #2750 · boto/boto3 · GitHub.

What is the difference between Boto3 client and Boto3 resource?

00:00 Boto3's primary function is to make AWS API calls for you. It extracts these APIs in two main ways: clients and resources. Clients give you low-level service access, while resources provide an object-oriented way of working with these services.


1 Answers

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) 
like image 54
Marty Avatar answered Sep 20 '22 21:09

Marty