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


Python ReconnectingClientFactory.buildProtocol方法代码示例

本文整理汇总了Python中twisted.internet.protocol.ReconnectingClientFactory.buildProtocol方法的典型用法代码示例。如果您正苦于以下问题:Python ReconnectingClientFactory.buildProtocol方法的具体用法?Python ReconnectingClientFactory.buildProtocol怎么用?Python ReconnectingClientFactory.buildProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.protocol.ReconnectingClientFactory的用法示例。


在下文中一共展示了ReconnectingClientFactory.buildProtocol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, address):
     """
     Calls the setup method of the protocal, passing in an instance
     of the factory
     """
     p = ReconnectingClientFactory.buildProtocol(self, address)
     p.setup(self)
     return p
开发者ID:jlew,项目名称:GrooveBot,代码行数:10,代码来源:JlewBot.py

示例2: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     p = ReconnectingClientFactory.buildProtocol(self, addr)
     print 'p:', p
     reactor.callLater(0, self.creator.callback, p)
     self.retries = 0
     self.delay = self.initialDelay
     self.factor = 1.6180339887498948
     return p
开发者ID:anson-tang,项目名称:3dkserver,代码行数:10,代码来源:reconnect.py

示例3: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
   try:
     #will create a protocol of the class given in self.protocol (set in the ctor)
     p = ReconnectingClientFactory.buildProtocol(self, addr)
   except Exception, e:
     #this could happen if, for instance, we can't start a helper prog (such as vboxwebsrv)
     reactor.stop()
     raise
开发者ID:dgquintas,项目名称:boincvm,代码行数:10,代码来源:StompProtocol.py

示例4: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     """Create a KafkaProtocol object, store it in self.proto, return it."""
     # Schedule notification of subscribers
     self._get_clock().callLater(0, self._notify, True)
     # Build the protocol
     self.proto = ReconnectingClientFactory.buildProtocol(self, addr)
     # point it at us for notifications of arrival of messages
     self.proto.factory = self
     return self.proto
开发者ID:joshainglis,项目名称:afkak,代码行数:11,代码来源:brokerclient.py

示例5: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     """
     Create a single protocol for communicating with game server's console.
     """
     client = ReconnectingClientFactory.buildProtocol(self, addr)
     client.parser = self.parser or ConsolePassthroughParser()
     client.timeout_value = self.timeout_value or REQUEST_TIMEOUT
     self.client = client
     return self.client
开发者ID:Kamyhin,项目名称:il2ds-events-commander,代码行数:11,代码来源:async.py

示例6: test_stopTryingWhenConnected

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [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:12019,项目名称:OpenWrt_Luci_Lua,代码行数:22,代码来源:test_factories.py

示例7: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     protocol = ReconnectingClientFactory.buildProtocol(self, addr)
     protocol.settings = self.settings
     # Set various properties defined by Twisted's IRCClient.
     protocol.nickname = self.settings.nickname or protocol.nickname
     protocol.password = self.settings.password or protocol.password
     protocol.realname = self.settings.realname or protocol.realname
     protocol.username = self.settings.username or protocol.username
     protocol.userinfo = self.settings.userinfo or protocol.userinfo
     self.protocols.add(protocol)
     return protocol
开发者ID:kxz,项目名称:omnipresence,代码行数:13,代码来源:connection.py

示例8: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
	def buildProtocol(self, address):
		proto = ReconnectingClientFactory.buildProtocol(self, address)
		proto.label = self.label
		proto.nickname = self.nickname
		proto.password = self.password
		proto.channels = self.channels
		proto.admins = self.admins
		proto.network = address
		proto.host = self.host
		proto.relay_active = True
		proto.debug = True
		proto.state = self.state
		proto.identifier = '%[email protected]%s' % (','.join(proto.channels), proto.host)
		return proto
开发者ID:gkistler,项目名称:pytwitchirc,代码行数:16,代码来源:twitch.py

示例9: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
    def buildProtocol(self, addr):
        # Build the protocol.
        p = ReconnectingClientFactory.buildProtocol(self, addr)

        # If we do not care about connecting to a slave, then we can simply
        # return the protocol now and fire that we are ready.
        if self.uri['options'].get('slaveok', False):
            self.setInstance(instance=p)
            return p

        # Update our server configuration. This may disconnect if the node
        # is not a master.
        p.connectionReady().addCallback(lambda _: self.configure(p))
        return p
开发者ID:bluehawksky,项目名称:txmongo,代码行数:16,代码来源:connection.py

示例10: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
	def buildProtocol(self, address):
		proto = ReconnectingClientFactory.buildProtocol(self, address)
		proto.container = self.container
		# for shortcut access:
		proto.settings = self.container._settings
		if proto.settings.enablestate: proto.state = self.container.state
		else: proto.state = None
		proto.dispatch = proto.settings.dispatcher.dispatch
		proto.dispatcher = proto.settings.dispatcher
		proto.nickname = proto.settings.nick
		#throttle queue
		proto._dqueue = deque()
		#debug
		proto.debug = proto.settings.debug
		return proto
开发者ID:ckx,项目名称:pyBurlyBot,代码行数:17,代码来源:client.py

示例11: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
    def buildProtocol(self, addr):
        # Build the protocol.
        p = ReconnectingClientFactory.buildProtocol(self, addr)

        ready_deferred = p.connectionReady()

        if not self.uri['options'].get('slaveok', False):
            # Update our server configuration. This may disconnect if the node
            # is not a master.
            ready_deferred.addCallback(lambda _: self.configure(p))

        ready_deferred\
            .addCallback(lambda _: self._auth_proto(p))\
            .addBoth(lambda _: self.setInstance(instance=p))
        return p
开发者ID:thachit,项目名称:txmongo,代码行数:17,代码来源:connection.py

示例12: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
    def buildProtocol(self, addr):
        # Build the protocol.
        p = ReconnectingClientFactory.buildProtocol(self, addr)

        log.err('connected to mongo %s' % addr)
        # on connection ensure we reset potential delays from previous
        # reconnect attempts
        self.resetDelay()

        # If we do not care about connecting to a slave, then we can simply
        # return the protocol now and fire that we are ready.
        if self.__slave_ok:
            p.connectionReady().addCallback(lambda _: self.setInstance(instance=p))
            # if we had reconnected, authenticate the db objects again
            if self.__reconnected:
                p.connectionReady().addCallback(lambda _: self.onReconnect())
            return p

        # Update our server configuration. This may disconnect if the node
        # is not a master.
        p.connectionReady().addCallback(lambda _: self.configure(p))

        return p
开发者ID:beevek,项目名称:txmongo,代码行数:25,代码来源:__init__.py

示例13: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     # Reset the ReconnectingClientFactory reconnect delay because we don't
     # want the next disconnect to force karmabot to delay forever.
     self.resetDelay()
     return ReconnectingClientFactory.buildProtocol(self, addr)
开发者ID:cboylan,项目名称:karmabot,代码行数:7,代码来源:client.py

示例14: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, address):
     '''Creates and instance of the client protocol and resets the
     connection delay.'''
     self.resetDelay()
     return ReconnectingClientFactory.buildProtocol(self, address)
开发者ID:dimitrov,项目名称:blfproxy,代码行数:7,代码来源:blfproxy.py

示例15: buildProtocol

# 需要导入模块: from twisted.internet.protocol import ReconnectingClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ReconnectingClientFactory import buildProtocol [as 别名]
 def buildProtocol(self, addr):
     print 'build protocol'
     return ReconnectingClientFactory.buildProtocol(self, addr)
开发者ID:JeffRoy,项目名称:ooi_port_agent,代码行数:5,代码来源:clientSimulator.py


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