Is there a way to kill a function in mid proccess?
Hi,In the docs there is an attribute forgradio.Button.click(cancels)But it seems like it doesn’t really exist.Is there a way to stop a function from running or to restart\reload the server if a button is being clicked?I tried demo.close() which closes the server but won’t restart/reload the server.Thank you for your wonderful support.
2022-11-08T22:14:33Z
Hi@LittleWing!Yes, you can use the cancels keyword!This was introduced in version 3.7 I believe.Take a look at this example:github.comgradio-app/gradio/blob/main/demo/cancel_events/run.pyimport time
import gradio as gr


def fake_diffusion(steps):
    for i in range(steps):
        print(f"Current step: {i}")
        time.sleep(1)
        yield str(i)


def long_prediction(*args, **kwargs):
    time.sleep(10)
    return 42


with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            n = gr.Slider(1, 10, value=9, step=1, label="Number Steps")This file has been truncated.show original
2022-11-10T20:39:52Z
Thank you so much!@freddyaboultonI needed to upgrade Gradio package, now I’m synced with the docs!one more tiny thing if I may, Do you have any idea if I can uncheck agr.Checkboxif I’m typing something on an inputgr.Textbox?I tried to play with it, but since I need to call a function undergr.Texbox.changeI can’t really achieve it.Thank you!!