本文整理汇总了Python中twisted.internet.protocol.ReconnectingClientFactory方法的典型用法代码示例。如果您正苦于以下问题:Python protocol.ReconnectingClientFactory方法的具体用法?Python protocol.ReconnectingClientFactory怎么用?Python protocol.ReconnectingClientFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol
的用法示例。
在下文中一共展示了protocol.ReconnectingClientFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stopTryingWhenConnected
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def test_stopTryingWhenConnected(self):
"""
If a L{ReconnectingClientFactory} has C{stopTrying} called while it is
connected, it does not subsequently attempt to reconnect if the
connection is later lost.
"""
class NoConnectConnector(object):
def stopConnecting(self):
raise RuntimeError("Shouldn't be called, we're connected.")
def connect(self):
raise RuntimeError("Shouldn't be reconnecting.")
c = ReconnectingClientFactory()
c.protocol = Protocol
# Let's pretend we've connected:
c.buildProtocol(None)
# Now we stop trying, then disconnect:
c.stopTrying()
c.clientConnectionLost(NoConnectConnector(), None)
self.assertFalse(c.continueTrying)
示例2: testStopTrying
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def testStopTrying(self):
f = Factory()
f.protocol = In
f.connections = 0
f.allMessages = []
f.goal = 2
f.d = defer.Deferred()
c = ReconnectingClientFactory()
c.initialDelay = c.delay = 0.2
c.protocol = Out
c.howManyTimes = 2
port = reactor.listenTCP(0, f)
self.addCleanup(port.stopListening)
PORT = port.getHost().port
reactor.connectTCP('127.0.0.1', PORT, c)
f.d.addCallback(self._testStopTrying_1, f, c)
return f.d
示例3: test_deserializationResetsParameters
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def test_deserializationResetsParameters(self):
"""
A L{ReconnectingClientFactory} which is unpickled does not have an
L{IConnector} and has its reconnecting timing parameters reset to their
initial values.
"""
factory = ReconnectingClientFactory()
factory.clientConnectionFailed(FakeConnector(), None)
self.addCleanup(factory.stopTrying)
serialized = pickle.dumps(factory)
unserialized = pickle.loads(serialized)
self.assertEqual(unserialized.connector, None)
self.assertEqual(unserialized._callID, None)
self.assertEqual(unserialized.retries, 0)
self.assertEqual(unserialized.delay, factory.initialDelay)
self.assertEqual(unserialized.continueTrying, True)
示例4: testStopTrying
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def testStopTrying(self):
f = Factory()
f.protocol = In
f.connections = 0
f.allMessages = []
f.goal = 2
f.d = defer.Deferred()
c = ReconnectingClientFactory()
c.initialDelay = c.delay = 0.2
c.protocol = Out
c.howManyTimes = 2
port = self.port = reactor.listenTCP(0, f)
PORT = port.getHost().port
reactor.connectTCP('127.0.0.1', PORT, c)
f.d.addCallback(self._testStopTrying_1, f, c)
return f.d
示例5: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = Doge
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例6: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = HighFiveBot
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例7: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = ChiefExecBot
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例8: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main(self):
f = protocol.ReconnectingClientFactory()
f.protocol = burnBot
serv_ip, serv_port = self.get_server_info()
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例9: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = LurkBot
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例10: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
serv_ip = 'coop.test.adtran.com'
serv_port = 6667
f = protocol.ReconnectingClientFactory()
f.protocol = pointBot
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例11: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = gooseBot
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例12: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = complimentBot
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例13: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = hangman
reactor.connectTCP("coop.test.adtran.com", 6667, f)
reactor.run()
示例14: main
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def main():
f = protocol.ReconnectingClientFactory()
f.protocol = Hulk
reactor.connectTCP(serv_ip, serv_port, f)
reactor.run()
示例15: buildProtocol
# 需要导入模块: from twisted.internet import protocol [as 别名]
# 或者: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
def buildProtocol(self, addr):
"""
Create a protocol instance.
Overrides L{XmlStreamFactoryMixin.buildProtocol} to work with
a L{ReconnectingClientFactory}. As this is called upon having an
connection established, we are resetting the delay for reconnection
attempts when the connection is lost again.
"""
self.resetDelay()
return XmlStreamFactoryMixin.buildProtocol(self, addr)