当前位置: 首页>>代码示例>>Python>>正文


Python protocol.ReconnectingClientFactory方法代码示例

本文整理汇总了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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:test_factories.py

示例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 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:test_factories.py

示例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) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:test_factories.py

示例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 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:21,代码来源:test_factories.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:doge.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:highFiveBot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:tom.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:burnBot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:lurkBot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:11,代码来源:pointBot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:gooseBot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:niceBot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:hangman_bot.py

示例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() 
开发者ID:AFTERWAKE,项目名称:IRCBots,代码行数:8,代码来源:hulk.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:xmlstream.py


注:本文中的twisted.internet.protocol.ReconnectingClientFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。