Created
November 30, 2021 14:15
-
-
Save eduzen/a1a39b244056d7bfbea2a10f030bcea6 to your computer and use it in GitHub Desktop.
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
from functools import wraps | |
import time | |
def try_until_you_find_it(retries=1, wait_time=1): | |
def decorator(func): | |
@wraps(func) | |
def wrapped_func(*args, **kwargs): | |
for n in range(retries): | |
try: | |
return func(*args, **kwargs) | |
except Exception as e: | |
print(str(e)) | |
time.sleep(wait_time) | |
return wrapped_func | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment