本文整理汇总了Python中thespian.system.transport.TransmitIntent.addCallback方法的典型用法代码示例。如果您正苦于以下问题:Python TransmitIntent.addCallback方法的具体用法?Python TransmitIntent.addCallback怎么用?Python TransmitIntent.addCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thespian.system.transport.TransmitIntent
的用法示例。
在下文中一共展示了TransmitIntent.addCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testTransmitIntentCallbackFailureFailedWithChangedTargetsAdded
# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import addCallback [as 别名]
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)])
示例2: testTransmitIntentCallbackSuccessWithChangedTargetsAdded
# 需要导入模块: from thespian.system.transport import TransmitIntent [as 别名]
# 或者: from thespian.system.transport.TransmitIntent import addCallback [as 别名]
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 == []