# Is there a way to kill a function in mid proccess?

**URL:** <https://discuss.huggingface.co/t/is-there-a-way-to-kill-a-function-in-mid-proccess/25708>\
**Category:** 🔒 Gradio\
**Created:** [November 7, 2022, 8:52pm UTC](https://discuss.huggingface.co/t/is-there-a-way-to-kill-a-function-in-mid-proccess/25708 "2022-11-07T20:52:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LittleWing](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@LittleWing](https://discuss.huggingface.co/u/LittleWing)\
**Post date:** [November 7, 2022, 8:52pm UTC](https://discuss.huggingface.co/t/is-there-a-way-to-kill-a-function-in-mid-proccess/25708/1 "2022-11-07T20:52:43Z")

</div>

Hi,

In the docs there is an attribute for `gradio.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.

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [November 8, 2022, 10:14pm UTC](https://discuss.huggingface.co/t/is-there-a-way-to-kill-a-function-in-mid-proccess/25708/2 "2022-11-08T22:14:33Z")

</div>

Hi @LittleWing !

Yes, you can use the cancels keyword!

This was introduced in version 3.7 I believe.

Take a look at this example:

> <https://github.com/gradio-app/gradio/blob/main/demo/cancel_events/run.py>

---

<div class="post-metadata">

**Author:** ![LittleWing](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@LittleWing](https://discuss.huggingface.co/u/LittleWing)\
**Post date:** [November 10, 2022, 8:39pm UTC](https://discuss.huggingface.co/t/is-there-a-way-to-kill-a-function-in-mid-proccess/25708/4 "2022-11-10T20:39:52Z")

</div>

Thank you so much! @freddyaboulton

I 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 a `gr.Checkbox` if I’m typing something on an input `gr.Textbox`?

I tried to play with it, but since I need to call a function under `gr.Texbox.change` I can’t really achieve it.

Thank you!!
