Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] callback_shared leads to infinite page loading #5

Open
anarchy16 opened this issue Mar 11, 2021 · 3 comments
Open

[BUG] callback_shared leads to infinite page loading #5

anarchy16 opened this issue Mar 11, 2021 · 3 comments

Comments

@anarchy16
Copy link

I want to make a button that changes its text upon click and triggers the next callback (plot update)

@app.callback(
    [Output("interval-graph", "disabled"), 
    Output("start-record-button", "buttonText")],
    [Input("start-record-button", "n_clicks")],
    [State("interval-graph", "disabled")],
)
def stop_GraphUpdate(n_clicks, current):
    if n_clicks == 0:
        return True, "Start record"
    return not current, "Stop Record" if current else "Start Record"

However, if I use callback_shared (which I want), page never loads and the Python script cannot be stopped with Ctrl + C.

Env

dash                      1.13.4
dash-bootstrap-components 0.11.3
dash-core-components      1.10.1
dash-daq                  0.5.0
dash-devices              0.1.3
dash-html-components      1.0.3
dash-renderer             1.5.1
dash-table                4.8.1

Describe the bug

What causes a problem is a button callback. If simplified:

import dash_devices
from dash_devices.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc

app = dash_devices.Dash(__name__)
app.config.suppress_callback_exceptions = True


app.layout = html.Div([
    html.Button(
        id = 'start-stop',
        n_clicks=0
        style={'width': 150, 'height':50, 'color':'orange'}
    ), 
])

@app.callback_shared(
    Output("start-stop", "children"),
    [Input("start-stop", "n_clicks")],
)

def button_text(n_clicks):
    if n_clicks == 0 or n_clicks %2 == 0:
        return "Start"
    else:
        return 'Stop'

if __name__ == "__main__":
    app.run_server(
    debug=True,
    host='localhost', port = 5000)
    

Which leads to infinite page loading.

Expected behavior

Observed only for callback_shared, callback behaves as it should.

@lucapinello
Copy link

I have the same problem. Did you find a solution?

@richlegrand
Copy link
Owner

Can you please give this wheel a try to see if it fixes the issue?

https://drive.google.com/file/d/1SLYmPLQv-HdDKZIjBF14PoC7P-AD7daV/view?usp=sharing

thanks :)

@lucapinello
Copy link

yes it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants