Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
	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 = '%s@%s' % (','.join(proto.channels), proto.host)
		return proto
Exemplo n.º 10
0
	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
Exemplo n.º 11
0
    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
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
 def buildProtocol(self, addr):
     self.resetDelay()
     return ReconnectingClientFactory.buildProtocol(self, addr)
Exemplo n.º 14
0
 def buildProtocol(self, addr):
     # Build the protocol.
     p = ReconnectingClientFactory.buildProtocol(self, addr)
     self._initializeProto(p)
     return p
 def buildProtocol(self, addr):
     self.resetDelay()
     #if not self.is_reconnecting: raise
     return ReconnectingClientFactory.buildProtocol(self, addr)
Exemplo n.º 16
0
 def buildProtocol(self, addr):
     self.resetDelay()
     self.addr = addr
     self.divvyProtocol = ReconnectingClientFactory.buildProtocol(self, addr)
     self.divvyProtocol.debug_mode = self.debug_mode
     return self.divvyProtocol
Exemplo n.º 17
0
 def buildProtocol(self, addr):
     print 'build protocol'
     return ReconnectingClientFactory.buildProtocol(self, addr)
Exemplo n.º 18
0
 def buildProtocol(self, addr):
     # Build the protocol.
     p = ReconnectingClientFactory.buildProtocol(self, addr)
     self._initializeProto(p)
     return p
Exemplo n.º 19
0
 def buildProtocol(self, p_addr):
     LOG.info('BuildProtocol - Addr = {}'.format(p_addr))
     _l_client = SamsungClient(self.m_pyhouse_obj, self.m_samsung_obj)
     l_ret = ReconnectingClientFactory.buildProtocol(self, p_addr)
     return l_ret
Exemplo n.º 20
0
 def buildProtocol(self, address):
     '''Creates and instance of the client protocol and resets the
     connection delay.'''
     self.resetDelay()
     return ReconnectingClientFactory.buildProtocol(self, address)
Exemplo n.º 21
0
 def buildProtocol(self, *args):
   print 'I: Connected.'
   self.resetDelay()
   return ReconnectingClientFactory.buildProtocol(self, *args)
Exemplo n.º 22
0
 def buildProtocol(self, addr):
     protocol = ReconnectingClientFactory.buildProtocol(self, addr)
     protocol.irc = self.irc
     return protocol
Exemplo n.º 23
0
 def buildProtocol(self, addr):
     p = ReconnectingClientFactory.buildProtocol(self, addr)
     p.callback = self.callback
     self.resetDelay()
     return p
Exemplo n.º 24
0
 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)
Exemplo n.º 25
0
 def buildProtocol(self, addr):
     protocol = ReconnectingClientFactory.buildProtocol(self, addr)
     protocol.irc = self.irc
     return protocol
Exemplo n.º 26
0
 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)
 def buildProtocol(self, addr):
     self.resetDelay()
     #if not self.is_reconnecting: raise
     return ReconnectingClientFactory.buildProtocol(self, addr)