def METHOD_NAME(self):
    tmpdirname = tempfile.mkdtemp()
    os.chmod(tmpdirname, 0o444)  # Make directory read-only
    nonwritable_path = os.path.join(tmpdirname, "flagging_dir")
    io = gr.Interface(
        lambda x: x,
        "text",
        "text",
        allow_flagging="never",
        flagging_dir=nonwritable_path,
    )
    io.launch(prevent_thread_lock=True)
    io.close()