daemon/core/broker.py
def addserver(self, name, host, port):
        ''' Add a new server, and try to connect to it. If we're already
            connected to this (host, port), then leave it alone. When host,port
            is None, do not try to connect.
        '''
        self.servers_lock.acquire()
        if name in self.servers:
            (oldhost, oldport, sock) = self.servers[name]
            if host == oldhost or port == oldport:
                # leave this socket connected
                if sock is not None:
                    self.servers_lock.release()
                    return
            if self.verbose and host is not None and sock is not None:
                self.session.info("closing connection with %s @ %s:%s" % \
                                  (name, host, port))
            if sock is not None:
                sock.close()
        self.servers_lock.release()
        if self.verbose and host is not None:
            self.session.info("adding server %s @ %s:%s" % (name, host, port))
        if host is None:
            sock = None
        else:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            #sock.setblocking(0)
            #error = sock.connect_ex((host, port))
            try:
                sock.connect((host, port))
                self.startrecvloop()
            except Exception, e:
                self.session.warn("error connecting to server %s:%s:\n\t%s" % \
                                  (host, port, e))
                sock.close()
                sock = None
        self.servers_lock.acquire()
        self.servers[name] = (host, port, sock)
        self.servers_lock.release()
 Add a new server, and try to connect to it. If we're already
            connected to this (host, port), then leave it alone. When host,port
            is None, do not try to connect.
        
Add a new server, and try to connect to it. If we're already
connected to this (host, port), then leave it alone. When host,port
is None, do not try to connect.
Add a new server and try to connect to it . If we ' re already connected to this ( host port ) then leave it alone . When host port is None do not try to connect .
def addserver(self, name, host, port):
        self.servers_lock.acquire()
        if name in self.servers:
            (oldhost, oldport, sock) = self.servers[name]
            if host == oldhost or port == oldport:
                if sock is not None:
                    self.servers_lock.release()
                    return
            if self.verbose and host is not None and sock is not None:
                self.session.info("closing connection with %s @ %s:%s" % \
                                  (name, host, port))
            if sock is not None:
                sock.close()
        self.servers_lock.release()
        if self.verbose and host is not None:
            self.session.info("adding server %s @ %s:%s" % (name, host, port))
        if host is None:
            sock = None
        else:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            try:
                sock.connect((host, port))
                self.startrecvloop()
            except Exception, e:
                self.session.warn("error connecting to server %s:%s:\n\t%s" % \
                                  (host, port, e))
                sock.close()
                sock = None
        self.servers_lock.acquire()
        self.servers[name] = (host, port, sock)
        self.servers_lock.release()
def addserver ( self , name , host , port ) : self . servers_lock . acquire ( ) if name in self . servers : ( oldhost , oldport , sock ) = self . servers [ name ] if host == oldhost or port == oldport : if sock is not None : self . servers_lock . release ( ) return if self . verbose and host is not None and sock is not None : self . session . info ( "closing connection with %s @ %s:%s" % ( name , host , port ) ) if sock is not None : sock . close ( ) self . servers_lock . release ( ) if self . verbose and host is not None : self . session . info ( "adding server %s @ %s:%s" % ( name , host , port ) ) if host is None : sock = None else : sock = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) try : sock . connect ( ( host , port ) ) self . startrecvloop ( ) except Exception , e : self . session . warn ( "error connecting to server %s:%s:\n\t%s" % ( host , port , e ) ) sock . close ( ) sock = None self . servers_lock . acquire ( ) self . servers [ name ] = ( host , port , sock ) self . servers_lock . release ( )
Add a new server, and try to connect to it.
Add a new server and try to connect to it .
''' Add a new server, and try to connect to it. If we're already
            connected to this (host, port), then leave it alone. When host,port
            is None, do not try to connect.
        ''' # leave this socket connected #sock.setblocking(0) #error = sock.connect_ex((host, port))
self
name
host
port