当前位置: 首页>>代码示例>>Python>>正文


Python Retry.get_backoff_time方法代码示例

本文整理汇总了Python中urllib3.util.retry.Retry.get_backoff_time方法的典型用法代码示例。如果您正苦于以下问题:Python Retry.get_backoff_time方法的具体用法?Python Retry.get_backoff_time怎么用?Python Retry.get_backoff_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib3.util.retry.Retry的用法示例。


在下文中一共展示了Retry.get_backoff_time方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_backoff_reset_after_redirect

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import get_backoff_time [as 别名]
 def test_backoff_reset_after_redirect(self):
     retry = Retry(total=100, redirect=5, backoff_factor=0.2)
     retry = retry.increment()
     retry = retry.increment()
     self.assertEqual(retry.get_backoff_time(), 0.4)
     redirect_response = HTTPResponse(status=302, headers={'location': 'test'})
     retry = retry.increment(response=redirect_response)
     self.assertEqual(retry.get_backoff_time(), 0)
     retry = retry.increment()
     retry = retry.increment()
     self.assertEqual(retry.get_backoff_time(), 0.4)
开发者ID:birm,项目名称:urllib3,代码行数:13,代码来源:test_retry.py

示例2: test_backoff_reset_after_redirect

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import get_backoff_time [as 别名]
 def test_backoff_reset_after_redirect(self):
     retry = Retry(total=100, redirect=5, backoff_factor=0.2)
     retry = retry.increment(method='GET')
     retry = retry.increment(method='GET')
     assert retry.get_backoff_time() == 0.4
     redirect_response = HTTPResponse(status=302, headers={'location': 'test'})
     retry = retry.increment(method='GET', response=redirect_response)
     assert retry.get_backoff_time() == 0
     retry = retry.increment(method='GET')
     retry = retry.increment(method='GET')
     assert retry.get_backoff_time() == 0.4
开发者ID:cloudera,项目名称:hue,代码行数:13,代码来源:test_retry.py

示例3: test_backoff

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import get_backoff_time [as 别名]
    def test_backoff(self):
        """ Backoff is computed correctly """
        max_backoff = Retry.BACKOFF_MAX

        retry = Retry(total=100, backoff_factor=0.2)
        self.assertEqual(retry.get_backoff_time(), 0) # First request

        retry = retry.increment()
        self.assertEqual(retry.get_backoff_time(), 0) # First retry

        retry = retry.increment()
        self.assertEqual(retry.backoff_factor, 0.2)
        self.assertEqual(retry.total, 98)
        self.assertEqual(retry.get_backoff_time(), 0.4) # Start backoff

        retry = retry.increment()
        self.assertEqual(retry.get_backoff_time(), 0.8)

        retry = retry.increment()
        self.assertEqual(retry.get_backoff_time(), 1.6)

        for i in xrange(10):
            retry = retry.increment()

        self.assertEqual(retry.get_backoff_time(), max_backoff)
开发者ID:birm,项目名称:urllib3,代码行数:27,代码来源:test_retry.py

示例4: test_backoff

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import get_backoff_time [as 别名]
    def test_backoff(self):
        """ Backoff is computed correctly """
        max_backoff = Retry.BACKOFF_MAX

        retry = Retry(total=100, backoff_factor=0.2)
        assert retry.get_backoff_time() == 0  # First request

        retry = retry.increment(method='GET')
        assert retry.get_backoff_time() == 0  # First retry

        retry = retry.increment(method='GET')
        assert retry.backoff_factor == 0.2
        assert retry.total == 98
        assert retry.get_backoff_time() == 0.4  # Start backoff

        retry = retry.increment(method='GET')
        assert retry.get_backoff_time() == 0.8

        retry = retry.increment(method='GET')
        assert retry.get_backoff_time() == 1.6

        for _ in xrange(10):
            retry = retry.increment(method='GET')

        assert retry.get_backoff_time() == max_backoff
开发者ID:cloudera,项目名称:hue,代码行数:27,代码来源:test_retry.py

示例5: test_zero_backoff

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import get_backoff_time [as 别名]
 def test_zero_backoff(self):
     retry = Retry()
     self.assertEqual(retry.get_backoff_time(), 0)
     retry = retry.increment()
     retry = retry.increment()
     self.assertEqual(retry.get_backoff_time(), 0)
开发者ID:birm,项目名称:urllib3,代码行数:8,代码来源:test_retry.py

示例6: test_zero_backoff

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import get_backoff_time [as 别名]
 def test_zero_backoff(self):
     retry = Retry()
     assert retry.get_backoff_time() == 0
     retry = retry.increment(method='GET')
     retry = retry.increment(method='GET')
     assert retry.get_backoff_time() == 0
开发者ID:cloudera,项目名称:hue,代码行数:8,代码来源:test_retry.py


注:本文中的urllib3.util.retry.Retry.get_backoff_time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。