(self)
Attempt to connect to the server.

        :returns: whether a connection is ready.
Attempt to connect to the server.
Attempt to connect to the server .
def connect(self):
        """
        Attempt to connect to the server.

        :returns: whether a connection is ready.
        """
        if self.server_connection is not None:
            return True

        if self.server_process is None:
            # Server process has exited but we already raised an exception
            return False

        return_code = self.server_process.poll()
        if return_code is not None:
            # Server process has exited
            stdout, stderr = self.server_process.communicate()
            self.server_process = None
            raise Exception(
                f"Pathfinding server process exited with return code {return_code}:\n"
                + stderr.decode()
            )

        try:
            # Attempt to connect
            self.server_connection = connection.Client(self.file_path)
            return True
        except FileNotFoundError:
            return False
def connect ( self ) : if self . server_connection is not None : return True if self . server_process is None : # Server process has exited but we already raised an exception return False return_code = self . server_process . poll ( ) if return_code is not None : # Server process has exited stdout , stderr = self . server_process . communicate ( ) self . server_process = None raise Exception ( f"Pathfinding server process exited with return code {return_code}:\n" + stderr . decode ( ) ) try : # Attempt to connect self . server_connection = connection . Client ( self . file_path ) return True except FileNotFoundError : return False