Created
December 10, 2024 06:24
-
-
Save FernandoCelmer/217444f57ba72cf25c6593f842f557c0 to your computer and use it in GitHub Desktop.
Retry
This file contains hidden or 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
| def retry(max_retry): | |
| def inside(func): | |
| def wrapper(*args, **kwargs): | |
| attempt = 0 | |
| error_output = None | |
| while max_retry > attempt: | |
| try: | |
| return func(*args, **kwargs) | |
| except Exception as error: | |
| error_output = error | |
| attempt += 1 | |
| log_exception(error_output) | |
| raise error_output | |
| return wrapper | |
| return inside |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment