✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Dash Timeout - Error Updating - How to Extend Timeout?

Hello,

I have an app that takes inputs and runs a long computation (> 10 minutes). The output of this computation is used to populate part of the app.layout. When I run the computation, the app gives me a callback error updating children.

I have tried the techniques for Sharing State Between Callbacks (Link), but they also fail.

Is there a way to get the app to wait for the output before throwing this error?

Here is a small reproducible sample:

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import State, Input, Output
from dash.exceptions import PreventUpdate
import time

app = dash.Dash(
    __name__, meta_tags=[{"name": "viewport", "content": "width=device-width"}]
)

app.layout = html.Div([
    html.Button(
        "Run",
        id="button1",
    ),
    dcc.Slider(
        id="slider1",
        min=0,
        max=10,
        step=1,
        value=0,
    ),
    dcc.Loading(
        id="Loading1",
        children=[
            html.Div(id="out1", children=[html.P("Nothing yet")]),
        ],
        type="default"
    )
])

@app.callback(Output('out1', 'children'),
              [Input('button1', 'n_clicks')],
              [State('slider1', 'value')])
def update_page(n_clicks, value):
    if n_clicks is None:
        raise PreventUpdate
    else:
        time.sleep(100)
        out_string = "The output is " + str(value)
        return html.P(out_string)

if __name__ == '__main__':
    app.run_server(debug=True)

Alternatively, do you think it would be better to have a callback with no output just to trigger the calculation?

Thanks,
Anthony

I have same problem. When I work with small data everything works fine but when working with big data after 1 min chrome said fetch failed.

Okay I solved https://stackoverflow.com/questions/24127601/uwsgi-request-timeout-in-python I use uwsgi to serve and http-timeout parameter works fine.

would you mind posting your solution? I’m reading the stackoverflow link but i’m not sure how to implement it