# Is there a timeout (max runtime) for spaces?

**URL:** <https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979>\
**Category:** Spaces\
**Created:** [December 20, 2021, 11:25am UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979 "2021-12-20T11:25:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Epoching](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/epoching/32/3493_2.png) [@Epoching](https://discuss.huggingface.co/u/Epoching)\
**Post date:** [December 20, 2021, 11:25am UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/1 "2021-12-20T11:25:16Z")

</div>

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 🙂 [3D\_Photo\_Inpainting - a Hugging Face Space by Classified](https://huggingface.co/spaces/Classified/3D_Photo_Inpainting)

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Epoching](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/epoching/32/3493_2.png) [@Epoching](https://discuss.huggingface.co/u/Epoching)\
**Post date:** [December 21, 2021, 2:03am UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/2 "2021-12-21T02:03:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Epoching](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/epoching/32/3493_2.png) [@Epoching](https://discuss.huggingface.co/u/Epoching)\
**Post date:** [December 21, 2021, 2:26am UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/3 "2021-12-21T02:26:03Z")

</div>

Update 2 / Solution:

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

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [December 21, 2021, 8:28am UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/4 "2021-12-21T08:28:29Z")

</div>

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

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

cc @cbensimon

---

<div class="post-metadata">

**Author:** ![Epoching](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/epoching/32/3493_2.png) [@Epoching](https://discuss.huggingface.co/u/Epoching)\
**Post date:** [December 21, 2021, 6:28pm UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/5 "2021-12-21T18:28:51Z")

</div>

I second this, would be a great feature! 🙂

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](https://discuss.huggingface.co/u/abidlabs)\
**Post date:** [December 22, 2021, 1:54pm UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/6 "2021-12-22T13:54:23Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![awacke1](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/awacke1/32/40934_2.png) [@awacke1](https://discuss.huggingface.co/u/awacke1)\
**Post date:** [March 31, 2022, 12:00am UTC](https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/7 "2022-03-31T00:00:09Z")

</div>

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