本文整理汇总了Python中twisted.internet.protocol.ClientFactory.attempts方法的典型用法代码示例。如果您正苦于以下问题:Python ClientFactory.attempts方法的具体用法?Python ClientFactory.attempts怎么用?Python ClientFactory.attempts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.ClientFactory
的用法示例。
在下文中一共展示了ClientFactory.attempts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getYobotPurpleFactory
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import attempts [as 别名]
def getYobotPurpleFactory(self):
f = ClientFactory()
f.protocol = YobotPurple
f.setPurple = self.setPurple
f.doRegister = self.purpleDoRegister
f.dispatch = self.purple_dispatch
#...
f.attempts = 0
max_attempts = 5
def clientConnectionFailed(connector, reason):
log_err("Attempt %d/%d failed: %s" % (f.attempts, max_attempts, reason))
if f.attempts < max_attempts:
log_info("trying again in 1.5 secs")
reactor.callLater(1.5, connector.connect)
f.attempts += 1
f.clientConnectionFailed = clientConnectionFailed
return f