Created
October 19, 2024 03:08
-
-
Save cjac/6b779fc680e6006783f6b0c578d7376b to your computer and use it in GitHub Desktop.
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_function( function_to_try, args ): | |
return_value=None | |
for try_number in range(0, 3): | |
try: | |
return_value = function_to_try( *args ) | |
if return_value is True: | |
break | |
raise Exception("function failed") | |
except: | |
time.sleep(2**try_number) | |
pass | |
raise Exception("Retry of function {} failed".format(function_to_try.__name__)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment