Skip to content

Instantly share code, notes, and snippets.

@ryanpeach
Created April 26, 2020 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanpeach/6501d6947d0073ba9db534a379497ddb to your computer and use it in GitHub Desktop.
Save ryanpeach/6501d6947d0073ba9db534a379497ddb to your computer and use it in GitHub Desktop.
Boto3 Throttling Replay Decorator
import time
import functools
from boto3.exceptions import ThrottlingException
def throttling_handler(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
while True:
try:
func(*args, **kwargs)
except ThrottlingException as e:
print("ThrottlingException, waiting 10sec and retrying.")
time.sleep(10)
continue
break
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment