#517·tenacity

统计数据为空

作者: setop创建于 2025年2月25日更新于 2025年3月16日

我需要了解一个函数进行了多少次尝试。我使用了 文档中的示例 (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)

执行时,输出为:

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

统计信息为空,我期望的是