本文整理汇总了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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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)
示例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)