python - 重试时的Python Tenacity日志异常
问题描述
我正在使用该tenacity
包重试一个功能。我的重试装饰器如下所示:
@retry(wait=wait_exponential(multiplier=1/(2**5), max=60), after=after_log(logger, logging.INFO))
在异常情况下,我会收到这样的日志消息:
INFO:mymodule:Finished call to 'mymodule.MyClass.myfunction' after 0.001(s), this was the 1st time calling it.
除了已经记录的内容之外,我还想记录实际的异常(1 行格式,最好不是堆栈跟踪)。有毅力能做到吗?还是我只需要捕获异常、打印并重新引发?
解决方案
推荐阅读
- python - 将字符串拆分为 Ysubn 字符串
- python - 当我尝试导入我的模块时,VSCode 运行会产生 ModuleNotFoundError
- haskell - VScode 中的 Haskell 错误:“扩展接口生成期间出错”
- julia - 以矩阵形式实现 OLS
- inno-setup - Inno 安装程序 - 如何在安装过程中检索环境变量?
- angular - Angular SwPush request订阅新的或旧的
- assembly - 如果 Thumb - 2 程序集中有一个寄存器,你如何按位反转所有值?
- ios - 如何在 Xcode 调试器中查看 RealmSwift 托管对象和属性
- mysql - 返回有能力打所有相同位置的球员
- javascript - 比较两个字符串的时间差(JS)