Python Tenacity log exception on retry
22:17 21 Sep 2020

I'm using the tenacity package to retry a function. My retry decorator looks like this:

@retry(wait=wait_exponential(multiplier=1/(2**5), max=60), after=after_log(logger, logging.INFO))

On exception I get a logging message like this:

INFO:mymodule:Finished call to 'mymodule.MyClass.myfunction' after 0.001(s), this was the 1st time calling it.

I want to log the actual exception (1-line format, not stack trace preferably) in addition to what is already logged. Can this be done with tenacity? Or do I just have to catch the exception, print, and re-raise?

python python-tenacity