I am trying to create a retry function in Python which is supposed to try to call any other function and in case of error of the called function repeat the call after some time.
My idea was to give any function as argument of my retry function which should look somehow like this:
def retry_function(function, retries):
for i in range(0, retries):
try:
print("Try no.:", str(i))
function
break
except Exception:
print("It was not succesful, trying again")
time.sleep(0.4)
continue
retry_function(some_other_function(..,..,..), 10)
My problem is, that I do not know how to try by this way every other function when they can have completely different types of arguments and the number of arguments. Is there a way to create this universal retry function? Or how should I call retry function with any function?
Thank you for any help