Is there a timeout (max runtime) for spaces?

I’ve been trying to make a 3d photo inpainting project work on huggingface spaces. After finally getting PyQt5 working with a headless display (lots of fun debugging via subprocess calls via python in app.py, since we don’t have access to the shell 0.0), it turns out spaces automatically timesout at around ~60 seconds?

The documentation said to use enable_queue=True in the iface.launch(enable_queue=True) function for gradio, but this doesn’t seem to help. Does HF Spaces automatically drop requests that span longer than 60 seconds? (the gradio timer on the spaces page counts up to 60, then prints error afterwards).

Checking the logs does show that the inference is able to finish running, but won’t be able to return anything back to the front-end via gradio since the connection gets cut.

Spaces currently set to private, but if any HF devs want to take a look & have access to private instances, here’s the link :slight_smile: 3D_Photo_Inpainting - a Hugging Face Space by Classified

Error on request:
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
    execute(self.server.app)
  File "/home/user/.local/lib/python3.8/site-packages/werkzeug/serving.py", line 311, in execute
    write(data)
  File "/home/user/.local/lib/python3.8/site-packages/werkzeug/serving.py", line 290, in write
    self.wfile.write(data)
  File "/usr/local/lib/python3.8/socketserver.py", line 826, in write
    self._sock.sendall(b)
TimeoutError: [Errno 110] Connection timed out
1 Like

Update: Making a simple app.py:

  • Input an image
  • sleep for 70 seconds
  • Output the same image

This results in the same thing (timing out after 60 seconds)
When changing the sleep to 50 seconds, it’s able to return the image.

Update 2 / Solution:

So turns out using enable_queue=True in launch() doesn’t work, e.g:

iface = gr.Interface(fn=..., inputs=..., outputs=...)
iface.launch(enable_queue=True)

After looking at the source code, I saw that enable_queue is a deprecated argument in Inference()
Doing the following fixed the 60 second timeout for me:

iface = gr.Interface(fn=..., inputs=..., outputs=..., enable_queue=True)
iface.launch()
3 Likes

Hi @Epoching. Glad you were able to fix it! :fire:

Moving forward, we plan to set enable_queue=True for all spaces by default.

cc @cbensimon

1 Like

I second this, would be a great feature! :slightly_smiling_face:

I’m glad you were able to make it work, @Epoching! I’m one of the developers of @Gradio and if you have any other feedback (in addition to what you’ve described above, which we’ll fix by enabling queue by default in Spaces), let me know!

1 Like

Thanks for the tip. This got me unstuck as well!