How to "time-out" or cancel processing when using Gradio.Interface.load()

I have a space which loads and runs a process to 12 different models at the same time using Gradio.Interface.load(). It works great unless 1 model fails to complete its job, or error out. Sometimes one or more models seem to just get stuck processing for eternity, and the queue then fills up with these processes, blocking any others.

I’m wondering if there is a way to cancel the process after a certain time, say 2 minutes, display an error message, and move on.

This is how I’m loading the models.
proc1=gr.Interface.load(f"models/{model_1}",live=False, preprocess=True, postprocess=False)

and this is the space:

Hi @Omnibus !

You can cancel running events if the queue is enabled in your demo: Blocks And Event Listeners

I don’t think you could do the cancelling automatically but you should be able to add a cancel button to do it manually.

1 Like

That’s awesome, thanks for the lead!