本文整理汇总了Python中urllib3.util.retry.Retry.is_exhausted方法的典型用法代码示例。如果您正苦于以下问题:Python Retry.is_exhausted方法的具体用法?Python Retry.is_exhausted怎么用?Python Retry.is_exhausted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib3.util.retry.Retry
的用法示例。
在下文中一共展示了Retry.is_exhausted方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_retry_total_none
# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_exhausted [as 别名]
def test_retry_total_none(self):
""" if Total is none, connect error should take precedence """
error = ConnectTimeoutError()
retry = Retry(connect=2, total=None)
retry = retry.increment(error=error)
retry = retry.increment(error=error)
with pytest.raises(MaxRetryError) as e:
retry.increment(error=error)
assert e.value.reason == error
error = ReadTimeoutError(None, "/", "read timed out")
retry = Retry(connect=2, total=None)
retry = retry.increment(method='GET', error=error)
retry = retry.increment(method='GET', error=error)
retry = retry.increment(method='GET', error=error)
assert not retry.is_exhausted()
示例2: test_retry_total_none
# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_exhausted [as 别名]
def test_retry_total_none(self):
""" if Total is none, connect error should take precedence """
error = ConnectTimeoutError()
retry = Retry(connect=2, total=None)
retry = retry.increment(error=error)
retry = retry.increment(error=error)
try:
retry.increment(error=error)
self.fail("Failed to raise error.")
except MaxRetryError as e:
self.assertEqual(e.reason, error)
error = ReadTimeoutError(None, "/", "read timed out")
retry = Retry(connect=2, total=None)
retry = retry.increment(error=error)
retry = retry.increment(error=error)
retry = retry.increment(error=error)
self.assertFalse(retry.is_exhausted())
示例3: test_retry_default
# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_exhausted [as 别名]
def test_retry_default(self):
""" If no value is specified, should retry connects 3 times """
retry = Retry()
self.assertEqual(retry.total, 10)
self.assertEqual(retry.connect, None)
self.assertEqual(retry.read, None)
self.assertEqual(retry.redirect, None)
error = ConnectTimeoutError()
retry = Retry(connect=1)
retry = retry.increment(error=error)
self.assertRaises(MaxRetryError, retry.increment, error=error)
retry = Retry(connect=1)
retry = retry.increment(error=error)
self.assertFalse(retry.is_exhausted())
self.assertTrue(Retry(0).raise_on_redirect)
self.assertFalse(Retry(False).raise_on_redirect)
示例4: test_retry_default
# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_exhausted [as 别名]
def test_retry_default(self):
""" If no value is specified, should retry connects 3 times """
retry = Retry()
assert retry.total == 10
assert retry.connect is None
assert retry.read is None
assert retry.redirect is None
error = ConnectTimeoutError()
retry = Retry(connect=1)
retry = retry.increment(error=error)
with pytest.raises(MaxRetryError):
retry.increment(error=error)
retry = Retry(connect=1)
retry = retry.increment(error=error)
assert not retry.is_exhausted()
assert Retry(0).raise_on_redirect
assert not Retry(False).raise_on_redirect