python - Python韧性: How to retry if exception is NOT of a certain type?

标签 python python-3.x exception error-handling python-tenacity

如果使用Python的顽强性,如果异常不是特定类型,如何重试函数?

如果出现某种类型的异常,retry_if_exception_type将重试。 not似乎无法在方法之前或其参数之前工作。

另一方面,即使没有出现错误,retry_unless_exception_type也会永远循环,直到出现某种类型的错误为止。

最佳答案

结合使用retry_unless_exception_type()stop_after_attempt()对我来说很有效。 stop_after_attempt()防止无限循环。

关于python - Python韧性: How to retry if exception is NOT of a certain type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59435875/

相关文章:

Java/数据库查询 : null or Excpetion?

java - 异常创建对象

python 如何查找从 2019 年 12 月开始并在两个日期列之间向前推进的每个月的天数

python - 使用 fuzzywuzzy 在数据框中创建新列

python - Python 中循环的奇怪行为

python - 如何处理有关将 int 应用于包含一项的系列的 FutureWarning?

python - 无法在 basemap Python中找到shapefile

python - Django-Filter:在搜索时动态创建查询集或在搜索之前隐藏查询集

python - 为什么 Pyglet 不能正确绘制多边形?

c# - 在 Azure Function 中找不到 EF 的 Getter 方法