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)
        except socket.error as error:
            if sock is not None:
                sock.close()
            _raise_connection_failure(self.address, error)

        sock_info = SocketInfo(sock, self, self.address)
        if self.handshake:
            sock_info.ismaster(self.opts.metadata, None)
        return sock_info
def connect ( self ) : sock = None try : sock = _configured_socket ( self . address , self . opts ) except socket . error as error : if sock is not None : sock . close ( ) _raise_connection_failure ( self . address , error ) sock_info = SocketInfo ( sock , self , self . address ) if self . handshake : sock_info . ismaster ( self . opts . metadata , None ) return sock_info
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.