# Gradio fn function errors right after 60 seconds

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%3E%5C
**Category:** Spaces\
**Created:** [December 22, 2021, 4:39pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048 "2021-12-22T16:39:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![un-index](https://avatars.discourse-cdn.com/v4/letter/u/9f8e36/32.png) [@un-index](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fun-index)%5C
**Post date:** [December 22, 2021, 4:39pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F1 "2021-12-22T16:39:39Z")

</div>

Always exactly after 60 seconds since execution, the function I pass to gradio.interface errors, and in the web console I get a JSON parsing error. I set `enable_queue` to True but that didn’t seem to change anything.

Here’s how I launch:

```python
iface = gr.Interface(f, [
    "text",
    temperature,
    top_p,
    gr.inputs.Slider(
        minimum=20, maximum=512, default=30, label="max length"),
    gr.inputs.Dropdown(["GPT-J-6B", "GPT-2"], type="index", label="model"),
    gr.inputs.Textbox(lines=1, placeholder="xxxxxxxx", label="space verification key")

], outputs="text", title=title, examples=examples)
iface.launch(enable_queue=True)  

```

How can I prevent it timing out after 60 seconds every time the function takes long?

![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/0/037aca82887745b5d86f400886d9e8a22a6125ac.png)  
_^as soon as that reaches 60, it errors_

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fosanseviero)%5C
**Post date:** [December 22, 2021, 8:38pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F2 "2021-12-22T20:38:24Z")

</div>

You can see [Is there a timeout (max runtime) for spaces? - #2 by Epoching](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-there-a-timeout-max-runtime-for-spaces%2F12979%2F2) or [the Gradio docs](https://gradio.app/docs/). You need to set `enable_queue` to `True` for longer inference

> - enable\_queue _(bool)_ - if True, inference requests will be served through a queue instead of with parallel threads. Required for longer inference times (\> 1min) to prevent timeout.

---

<div class="post-metadata">

**Author:** ![un-index](https://avatars.discourse-cdn.com/v4/letter/u/9f8e36/32.png) [@un-index](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fun-index)%5C
**Post date:** [December 22, 2021, 9:44pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F3 "2021-12-22T21:44:04Z")

</div>

yeah, key thing was I had to use `enable=True` within `interface(...)`, not within an `interface` **`.launch`** call.

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fabidlabs)%5C
**Post date:** [December 23, 2021, 1:12am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F4 "2021-12-23T01:12:39Z")

</div>

Yes, this is an issue that we’re dealing with ([Investigate `enable_queue` · Issue #431 · gradio-app/gradio (github.com)](https://github.com/gradio-app/gradio/issues/431)). Thanks for bringing it to our attention.

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fabidlabs)%5C
**Post date:** [December 23, 2021, 7:08pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F5 "2021-12-23T19:08:00Z")

</div>

As of the latest version of Gradio (`2.6.0`), this should be fixed. But please let me know if you still are running into issues @un-index

---

<div class="post-metadata">

**Author:** ![un-index](https://avatars.discourse-cdn.com/v4/letter/u/9f8e36/32.png) [@un-index](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fun-index)%5C
**Post date:** [December 24, 2021, 8:44pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F6 "2021-12-24T20:44:32Z")

</div>

I got it per [this comment](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F3)%2C thanks

---

<div class="post-metadata">

**Author:** ![anirban2709](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@anirban2709](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fanirban2709)%5C
**Post date:** [June 21, 2023, 9:36am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-fn-function-errors-right-after-60-seconds%2F13048%2F7 "2023-06-21T09:36:58Z")

</div>

“enable\_queue = True” still works
