本文整理汇总了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()
示例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
示例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))
示例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)
示例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())
示例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())
示例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
示例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())
示例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()