def METHOD_NAME(port, tbl, done_event):
    conn = r.connect("localhost", port)
    try:
        if tbl is None:
            r.db(db).wait(wait_for="all_replicas_ready").run(conn)
        else:
            res = r.db(db).table(tbl).wait(wait_for="all_replicas_ready").run(conn)
            assert res["ready"] == 1
    finally:
        done_event.set()