def METHOD_NAME(hostinfo: HostInfo, workdir: str, recv_conn: mp_connection.Connection,
                send_conn: mp_connection.Connection, env: dict) -> None:
    """
    Use fabric connection to execute command on local or remote hosts.
    Args:
        hostinfo (HostInfo): host information
        workdir (str): the directory to execute the command
        recv_conn (multiprocessing.connection.Connection): receive messages from the master sender
        send_conn (multiprocessing.connection.Connection): send messages to the master receiver
        env (dict): a dictionary for environment variables
    """
    fab_conn = fabric.Connection(hostinfo.hostname, port=hostinfo.port)
    finish = False
    env_msg = ' '.join([f'{k}=\"{v}\"' for k, v in env.items()])
    # keep listening until exit
    while not finish:
        # receive cmd
        cmds = recv_conn.recv()
        if cmds == 'exit':
            # exit from the loop
            finish = True
            break
        else:
            # execute the commands
            try:
                # cd to execute directory
                with fab_conn.cd(workdir):
                    # propagate the runtime environment
                    with fab_conn.prefix(f"export {env_msg}"):
                        if hostinfo.is_local_host:
                            # execute on the local machine
                            fab_conn.local(cmds, hide=False)
                        else:
                            # execute on the remote machine
                            fab_conn.run(cmds, hide=False)
                    send_conn.send('success')
            except Exception as e:
                click.echo(
                    f"Error: failed to run {cmds} on {hostinfo.hostname}, is localhost: {hostinfo.is_local_host}, exception: {e}"
                )
                send_conn.send('failure')
    # shutdown
    send_conn.send("finish")
    fab_conn.close()