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


Python TransmitIntent.retry方法代码示例

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


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

示例1: testTransmitIntentRetryTimingExceedsLimit

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
    def testTransmitIntentRetryTimingExceedsLimit(self):
        maxPeriod = timedelta(seconds=90)
        period = timedelta(microseconds=1)
        now = 1.23
        timepad = timedelta(microseconds=10) # avoid float imprecision
        with update_elapsed_time(now, timedelta(0)):
            ti = TransmitIntent('addr', 'msg',
                                maxPeriod=maxPeriod,
                                retryPeriod=period)
            assert not ti.timeToRetry()

        timeoffset = timedelta(0)
        for N in range(MAX_TRANSMIT_RETRIES+1):
            # Indicate "failure" and the need to retry
            with update_elapsed_time(now, timeoffset + timepad):
                assert ti.retry()
            # Wait for the indication that it is time to retry
            time_to_retry = False
            for x in range(90):
                with update_elapsed_time(now, timeoffset + timepad):
                    # Only call timeToRetry once, because it auto-resets
                    time_to_retry = ti.timeToRetry()
                    if time_to_retry: break
                timeoffset += (period + (period / 2))
                # = period * 1.5, but python2 cannot multiply
                # timedelta by fractions.
            assert time_to_retry

        with update_elapsed_time(now, timeoffset + timepad):
            assert not ti.retry()
开发者ID:godaddy,项目名称:Thespian,代码行数:32,代码来源:test_transmitintent.py

示例2: testTransmitIntentRetryTiming

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
    def testTransmitIntentRetryTiming(self):
        maxPeriod = timedelta(milliseconds=90)
        period = timedelta(milliseconds=30)
        now = 0.01
        timepad = timedelta(microseconds=10) # avoid float imprecision
        with update_elapsed_time(now, timedelta(0)):
            ti = TransmitIntent('addr', 'msg',
                                maxPeriod=maxPeriod,
                                retryPeriod=period)
            assert not ti.timeToRetry()

        with update_elapsed_time(now, period + timepad):
            assert not ti.timeToRetry()

            assert ti.retry()
            assert not ti.timeToRetry()

        with update_elapsed_time(now, period + period + timepad):
            assert ti.timeToRetry()
            assert ti.retry()
            assert not ti.timeToRetry()

        with update_elapsed_time(now, period * 3 + timepad):
            assert not ti.timeToRetry()  # Each retry increases

        with update_elapsed_time(now, period * 4 + timepad):
            assert ti.timeToRetry()
            assert not ti.retry()  # Exceeds maximum time
开发者ID:godaddy,项目名称:Thespian,代码行数:30,代码来源:test_transmitintent.py

示例3: testTransmitIntentRetryDelay

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
 def testTransmitIntentRetryDelay(self):
     maxPeriod = timedelta(milliseconds=90)
     period = timedelta(milliseconds=30)
     ti = TransmitIntent('addr', 'msg', maxPeriod=maxPeriod, retryPeriod=period)
     ti.retry()
     delay = ti.delay()
     self.assertGreater(delay, timedelta(milliseconds=28))
     self.assertLess(delay, timedelta(milliseconds=31))
开发者ID:liuzhijun,项目名称:Thespian,代码行数:10,代码来源:test_transmitintent.py

示例4: testTransmitIntentRetryDelay

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
 def testTransmitIntentRetryDelay(self):
     maxPeriod = timedelta(milliseconds=90)
     period = timedelta(milliseconds=30)
     ti = TransmitIntent('addr', 'msg',
                         maxPeriod=maxPeriod,
                         retryPeriod=period)
     ti.retry()
     delay = ti.delay()
     assert delay > timedelta(milliseconds=28)
     assert delay < timedelta(milliseconds=31)
开发者ID:godaddy,项目名称:Thespian,代码行数:12,代码来源:test_transmitintent.py

示例5: testTransmitIntentRetryTimingExceedsLimit

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
    def testTransmitIntentRetryTimingExceedsLimit(self):
        maxPeriod = timedelta(seconds=90)
        period = timedelta(microseconds=1)
        ti = TransmitIntent('addr', 'msg', maxPeriod=maxPeriod, retryPeriod=period)
        self.assertFalse(ti.timeToRetry())

        for N in range(MAX_TRANSMIT_RETRIES+1):
            self.assertTrue(ti.retry())
            for x in range(90):
                if ti.timeToRetry(): break
                sleep(timePeriodSeconds(period))
            self.assertTrue(ti.timeToRetry())

        self.assertFalse(ti.retry())
开发者ID:jfasenfest,项目名称:Thespian,代码行数:16,代码来源:test_transmitintent.py

示例6: testTransmitIntentRetryTimingExceedsLimit

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
    def testTransmitIntentRetryTimingExceedsLimit(self):
        maxPeriod = timedelta(seconds=90)
        period = timedelta(microseconds=1)
        ti = TransmitIntent('addr', 'msg', maxPeriod=maxPeriod, retryPeriod=period)
        self.assertFalse(ti.timeToRetry())

        for N in range(MAX_TRANSMIT_RETRIES+1):
            # Indicate "failure" and the need to retry
            self.assertTrue(ti.retry())
            # Wait for the indication that it is time to retry
            time_to_retry = False
            for x in range(90):
                # Only call timeToRetry once, because it auto-resets
                time_to_retry = ti.timeToRetry()
                if time_to_retry: break
                sleep(timePeriodSeconds(period) * 1.5)
            self.assertTrue(time_to_retry)

        self.assertFalse(ti.retry())
开发者ID:liuzhijun,项目名称:Thespian,代码行数:21,代码来源:test_transmitintent.py

示例7: testTransmitIntentRetryTiming

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
    def testTransmitIntentRetryTiming(self):
        maxPeriod = timedelta(milliseconds=90)
        period = timedelta(milliseconds=30)
        ti = TransmitIntent('addr', 'msg', maxPeriod=maxPeriod, retryPeriod=period)
        self.assertFalse(ti.timeToRetry())
        sleep(timePeriodSeconds(period))
        self.assertFalse(ti.timeToRetry())

        self.assertTrue(ti.retry())
        self.assertFalse(ti.timeToRetry())
        sleep(timePeriodSeconds(period))
        self.assertTrue(ti.timeToRetry())

        self.assertTrue(ti.retry())
        self.assertFalse(ti.timeToRetry())
        sleep(timePeriodSeconds(period))
        self.assertFalse(ti.timeToRetry())  # Each retry increases
        sleep(timePeriodSeconds(period))
        self.assertTrue(ti.timeToRetry())

        self.assertFalse(ti.retry())  # Exceeds maximum time
开发者ID:liuzhijun,项目名称:Thespian,代码行数:23,代码来源:test_transmitintent.py

示例8: testTransmitIntentRetry

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
 def testTransmitIntentRetry(self):
     ti = TransmitIntent('addr', 'msg')
     for x in range(MAX_TRANSMIT_RETRIES+1):
         self.assertTrue(ti.retry())
     self.assertFalse(ti.retry())
开发者ID:liuzhijun,项目名称:Thespian,代码行数:7,代码来源:test_transmitintent.py

示例9: testTransmitIntentRetry

# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import retry [as 别名]
 def testTransmitIntentRetry(self):
     ti = TransmitIntent('addr', 'msg')
     for x in range(MAX_TRANSMIT_RETRIES+1):
         assert ti.retry()
     assert not ti.retry()
开发者ID:godaddy,项目名称:Thespian,代码行数:7,代码来源:test_transmitintent.py


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