當前位置: 首頁>>代碼示例>>Python>>正文


Python transport.TransmitIntent類代碼示例

本文整理匯總了Python中thespian.system.transport.TransmitIntent的典型用法代碼示例。如果您正苦於以下問題:Python TransmitIntent類的具體用法?Python TransmitIntent怎麽用?Python TransmitIntent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TransmitIntent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testTransmitIntentSetResult

 def testTransmitIntentSetResult(self):
     ti = TransmitIntent('addr', 'msg')
     assert None == ti.result
     ti.result = SendStatus.Sent
     assert ti.result == SendStatus.Sent
     ti.result = SendStatus.Failed
     assert ti.result == SendStatus.Failed
開發者ID:godaddy,項目名稱:Thespian,代碼行數:7,代碼來源:test_transmitintent.py

示例2: testTransmitIntentRetryTimingExceedsLimit

    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,代碼行數:30,代碼來源:test_transmitintent.py

示例3: testNormalTransmitResetMessage

 def testNormalTransmitResetMessage(self):
     ti = TransmitIntent('addr', 'msg')
     assert ti.targetAddr == 'addr'
     assert ti.message == 'msg'
     ti.changeMessage('message2')
     assert ti.targetAddr == 'addr'
     assert ti.message == 'message2'
開發者ID:godaddy,項目名稱:Thespian,代碼行數:7,代碼來源:test_transmitintent.py

示例4: testTransmitIntentDelay

 def testTransmitIntentDelay(self):
     maxPeriod = timedelta(milliseconds=90)
     period = timedelta(milliseconds=30)
     ti = TransmitIntent('addr', 'msg', maxPeriod=maxPeriod, retryPeriod=period)
     delay = ti.delay()
     self.assertGreater(delay, timedelta(milliseconds=88))
     self.assertLess(delay, timedelta(milliseconds=91))
開發者ID:liuzhijun,項目名稱:Thespian,代碼行數:7,代碼來源:test_transmitintent.py

示例5: testNormalTransmitResetMessage

 def testNormalTransmitResetMessage(self):
     ti = TransmitIntent('addr', 'msg')
     self.assertEqual(ti.targetAddr, 'addr')
     self.assertEqual(ti.message, 'msg')
     ti.changeMessage('message2')
     self.assertEqual(ti.targetAddr, 'addr')
     self.assertEqual(ti.message, 'message2')
開發者ID:liuzhijun,項目名稱:Thespian,代碼行數:7,代碼來源:test_transmitintent.py

示例6: testTransmitIntentSetResult

 def testTransmitIntentSetResult(self):
     ti = TransmitIntent('addr', 'msg')
     self.assertEqual(None, ti.result)
     ti.result = SendStatus.Sent
     self.assertEqual(ti.result, SendStatus.Sent)
     ti.result = SendStatus.Failed
     self.assertEqual(ti.result, SendStatus.Failed)
開發者ID:liuzhijun,項目名稱:Thespian,代碼行數:7,代碼來源:test_transmitintent.py

示例7: testTransmitIntentDelay

 def testTransmitIntentDelay(self):
     maxPeriod = timedelta(milliseconds=90)
     period = timedelta(milliseconds=30)
     ti = TransmitIntent('addr', 'msg',
                         maxPeriod=maxPeriod,
                         retryPeriod=period)
     delay = ti.delay()
     assert delay > timedelta(milliseconds=88)
     assert delay < timedelta(milliseconds=91)
開發者ID:godaddy,項目名稱:Thespian,代碼行數:9,代碼來源:test_transmitintent.py

示例8: testTransmitIntentRetryTimingExceedsLimit

    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,代碼行數:19,代碼來源:test_transmitintent.py

示例9: testTransmitIntentCallbackFailureFailed

 def testTransmitIntentCallbackFailureFailed(self):
     ti = TransmitIntent('addr', 'msg')
     ti.result = SendStatus.Failed
     # Ensure no exception thrown
     ti.completionCallback()
     # And again
     ti.completionCallback()
開發者ID:liuzhijun,項目名稱:Thespian,代碼行數:7,代碼來源:test_transmitintent.py

示例10: testTransmitIntentCallbackFailureFailedWithChangedTargetsAdded

 def testTransmitIntentCallbackFailureFailedWithChangedTargetsAdded(self):
     self.successes = []
     self.failures = []
     ti = TransmitIntent('addr', 'msg', onSuccess = self._success, onError = self._failed)
     ti.result = SendStatus.Failed
     # Ensure no exception thrown
     ti.completionCallback()
     self.assertEqual(self.successes, [])
     self.assertEqual(self.failures, [(SendStatus.Failed, ti)])
     # And again
     ti.addCallback(self._success, self._failed)
     ti.completionCallback()
     self.assertEqual(self.successes, [])
     self.assertEqual(self.failures, [(SendStatus.Failed, ti), (SendStatus.Failed, ti)])
開發者ID:liuzhijun,項目名稱:Thespian,代碼行數:14,代碼來源:test_transmitintent.py

示例11: testTransmitIntentCallbackSuccessWithChangedTargetsAdded

 def testTransmitIntentCallbackSuccessWithChangedTargetsAdded(self):
     self.successes = []
     self.failures = []
     ti = TransmitIntent('addr', 'msg',
                         onSuccess = self._success,
                         onError = self._failed)
     ti.result = SendStatus.Sent
     # Ensure no exception thrown
     ti.completionCallback()
     assert self.successes == [(SendStatus.Sent, ti)]
     assert self.failures == []
     # And again
     ti.addCallback(self._success, self._failed)
     ti.completionCallback()
     assert self.successes == [(SendStatus.Sent, ti), (SendStatus.Sent, ti)]
     assert self.failures == []
開發者ID:godaddy,項目名稱:Thespian,代碼行數:16,代碼來源:test_transmitintent.py

示例12: testTransmitIntentCallbackFailureNotSentWithTarget

 def testTransmitIntentCallbackFailureNotSentWithTarget(self):
     self.successes = []
     self.failures = []
     ti = TransmitIntent('addr', 'msg', onSuccess = self._success, onError = self._failed)
     ti.result = SendStatus.NotSent
     # Ensure no exception thrown
     ti.completionCallback()
     self.assertEqual(self.successes, [])
     self.assertEqual(self.failures, [(SendStatus.NotSent, ti)])
     # And again
     ti.completionCallback()
     self.assertEqual(self.successes, [])
     self.assertEqual(self.failures, [(SendStatus.NotSent, ti)])
開發者ID:liuzhijun,項目名稱:Thespian,代碼行數:13,代碼來源:test_transmitintent.py

示例13: testTransmitIntentRetryTimingExceedsLimit

    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,代碼行數:14,代碼來源:test_transmitintent.py

示例14: testTransmitIntentCallbackFailureFailedWithTarget

 def testTransmitIntentCallbackFailureFailedWithTarget(self):
     self.successes = []
     self.failures = []
     ti = TransmitIntent('addr', 'msg',
                         onSuccess = self._success,
                         onError = self._failed)
     ti.result = SendStatus.Failed
     # Ensure no exception thrown
     ti.completionCallback()
     assert self.successes == []
     assert self.failures == [(SendStatus.Failed, ti)]
     # And again
     ti.completionCallback()
     assert self.successes == []
     assert self.failures == [(SendStatus.Failed, ti)]
開發者ID:godaddy,項目名稱:Thespian,代碼行數:15,代碼來源:test_transmitintent.py

示例15: testTransmitIntentRetry

 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,代碼行數:5,代碼來源:test_transmitintent.py


注:本文中的thespian.system.transport.TransmitIntent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。