def METHOD_NAME(
    session_id=None,
    poll_interval=10,
    host="localhost",
    port=constants.ISLAND_DEFAULT_REST_PORT,
    timeout=30,
    status_dump_path=None,
):
    """
    Monitors the execution status of all sessions (or the single session
    specified by `session_id`) by polling `host`:`port`, and returns when they
    all have finished executing.
    """
    client = _get_client(host, port, timeout, status_dump_path)
    if session_id:
        while True:
            session = client.session(session_id)
            if _session_finished(session):
                return _session_status(session)
            time.sleep(poll_interval)
    else:
        while True:
            sessions = client.sessions()
            if all(_session_finished(s) for s in sessions):
                return {s["sessionId"]: _session_status(s) for s in sessions}
            time.sleep(poll_interval)