(self)
Connect to Mongo and return a new SocketInfo.

        Can raise ConnectionFailure or CertificateError.

        Note that the pool does not keep a reference to the socket -- you
        must call return_socket() when you're done with it.
Connect to Mongo and return a new SocketInfo.
Connect to Mongo and return a new SocketInfo .
def connect(self):
        """Connect to Mongo and return a new SocketInfo.

        Can raise ConnectionFailure or CertificateError.

        Note that the pool does not keep a reference to the socket -- you
        must call return_socket() when you're done with it.
        """
        sock = None
        try:
            sock = _configured_socket(self.address, self.opts)
            if self.handshake:
                cmd = SON([
                    ('ismaster', 1),
                    ('client', self.opts.metadata)
                ])
                ismaster = IsMaster(
                    command(sock,
                            'admin',
                            cmd,
                            False,
                            False,
                            ReadPreference.PRIMARY,
                            DEFAULT_CODEC_OPTIONS))
            else:
                ismaster = None
            return SocketInfo(sock, self, ismaster, self.address)
        except socket.error as error:
            if sock is not None:
                sock.close()
            _raise_connection_failure(self.address, error)
def connect ( self ) : sock = None try : sock = _configured_socket ( self . address , self . opts ) if self . handshake : cmd = SON ( [ ( 'ismaster' , 1 ) , ( 'client' , self . opts . metadata ) ] ) ismaster = IsMaster ( command ( sock , 'admin' , cmd , False , False , ReadPreference . PRIMARY , DEFAULT_CODEC_OPTIONS ) ) else : ismaster = None return SocketInfo ( sock , self , ismaster , self . address ) except socket . error as error : if sock is not None : sock . close ( ) _raise_connection_failure ( self . address , error )