def METHOD_NAME(port, query_id, max_tries=100):
    """
    Send zmq message to flowmachine on port `port` which polls the
    query with id `query_id` until the return status is "completed".
    """
    host = "localhost"
    msg = {
        "action": "poll_query",
        "params": {"query_id": query_id},
        "request_id": "DUMMY_ID",
    }
    for i in itertools.count():
        if i > max_tries:
            raise RuntimeError("Timeout reached but query is not done. Aborting.")
        print(f"[DDD] Polling query {query_id}...")
        reply = send_zmq_message_and_receive_reply(msg, port=port, host=host)
        if "completed" == reply["payload"]["query_state"]:
            break
        time.sleep(0.1)