gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
29.49k stars 2.19k forks source link

Cancelling a python client job won't stop the job from running on the server #8188

Closed freddyaboulton closed 1 week ago

freddyaboulton commented 2 weeks ago

Describe the bug

If you cancel a job with the client, it will keep running on the remote server.

I think the reason is that cancel will only tell the thread that's pulling results off the queue that it should stop. It won't stop the thread that's connecting to the server.

Have you searched existing issues? 🔎

Reproduction

Run the cancel_events demo (increase the sleep to 1 second so that you have time to cancel)

from gradio_client import Client
client = Client("http://127.0.0.1:7860")
job = client.submit(7, api_name="/fake_diffusion")
job.cancel()

You will see that the server keeps printing output in the console

Screenshot

cancel_python

Logs

No response

System Info

main

Severity

Blocking usage of gradio