Spaces:
Runtime error

fffiloni commited on
Commit
c80c42f
·
verified ·
1 Parent(s): 446c7ea

Add timeout to prediction polling to prevent queue lock

Browse files

Previously, the Gradio app would poll the Cog prediction status indefinitely, waiting for a "succeeded" or "failed" response. If the Cog server became unresponsive or a prediction hung (e.g. due to a bad input or internal model error), the polling loop would never exit.

This behavior caused the Gradio queue to back up and eventually stall completely under high load, since all workers could get stuck waiting for unresponsive predictions.

This change introduces a timeout mechanism (60 seconds) in the polling loop. If the prediction doesn't complete within that time, an error is raised and the request is gracefully terminated. This helps avoid queue deadlocks and improves reliability under concurrent usage.

1 file changed +30 -18
app.py+30-18