Created
April 26, 2020 03:12
-
-
Save ryanpeach/6501d6947d0073ba9db534a379497ddb to your computer and use it in GitHub Desktop.
Boto3 Throttling Replay Decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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