Skip to content

Instantly share code, notes, and snippets.

@cjac
Created October 19, 2024 03:08
Show Gist options
  • Save cjac/6b779fc680e6006783f6b0c578d7376b to your computer and use it in GitHub Desktop.
Save cjac/6b779fc680e6006783f6b0c578d7376b to your computer and use it in GitHub Desktop.
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