LoginSignup
5
3

More than 5 years have passed since last update.

boto3でリトライの設定を変更する

Posted at

python 3.7
boto3 1.4.4

AWS でのエラーの再試行とエクスポネンシャルバックオフ

各 AWS SDK は、自動再試行ロジックを実装しています

設定ファイルで変更するか、コードで変更するかのどちらか
設定ファイルの場合、AWS CLIでも有効になる

設定ファイル

~/.aws/models/_retry.jsonを用意する。書き方はbotocoreパッケージの_retry.jsonと同じ。
http://botocore.readthedocs.io/en/latest/reference/loaders.html

clientのリトライハンドラーの持つ値を直接変更する

boto2.num_retries equivalent in retryhandler.py or _retry.json #882

import boto3

client = boto3.client('stepfunctions')
client.meta.events._unique_id_handlers['retry-config-states']['handler']._checker.__dict__['_max_attempts'] = 1

retry-config-statesstates部分はサービスごとの値。上の例だと、stepfunctionsでの再試行回数を1に設定している。


現在、セッションごとに設定値を指定できるようなPRがマージを待ってる
Add possibility of modifying retry_config #891

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3