#517·tenacity

statistics are empty

Author: setopCreated Feb 25, 2025Updated Mar 16, 2025

I needed to know how many retries a function made.

I used the example in the doc (v9.0.0):

python
from tenacity import *

@retry(stop=stop_after_attempt(3))
def raise_my_exception():
    raise Exception("Fail")

try:
    raise_my_exception()
except Exception as e:
    print(e)
    pass

print(raise_my_exception.retry.statistics)

when executing:

bash
RetryError[<Future at 0x7ffb5b7902d0 state=finished raised Exception>]
{}

statistics are empty

I was expecting

python
{ "attempt_number" : 3 }