Method for Controlling Retries when calling a @retry decorated function inside ANOTHER @retry decorated function
I am looking for an elegant solution to stop the function_that_can_fail function from being called 100 times in the following contrived scenario.
@retry(stop=stop_after_attempt(10))
def function_a():
return function_that_can_fail()
@retry(stop=stop_after_attempt(10))
def function_b():
content = function_a()
session.post(content, "http://some_url.com")
function_a() retries 10x for each retry of function_b() which also retries 10x.
The functions that I'm working with are both decorated and can't really be changed to no decorator.
Is there anything that isn't too hacky that I should look at implementing?
I think ideally, function_a() would not even have its own notion of a retry, and the higher level function_b() would retry up to 10 times if function_a() were to throw an exception.
Thank you for your time.
Please excuse me, I believe I have located the solution in the documentation.
https://github.com/jd/tenacity#changing-arguments-at-run-time in case someone else comes looking