Iām having the same issue with the latest version of dash. This code reproduces the issue:
test_div = html.Div(id="test_div")
trigger_div = html.Div(id="trigger_div")
test_button = dbc.Button("test", id="test_button")
@app.callback(
[
Output(test_button.id, "disabled"),
],
[Input(test_button.id, "n_clicks"), Input(trigger_div.id, "children")],
[State(test_button.id, "disabled")],
)
def trigger_function(n_clicks, trigger, is_disabled):
import logging
logging.getLogger("test").info(f"trigger! n_clicks: {n_clicks}. trigger: {trigger}, is_disabled: {is_disabled}")
if n_clicks is None and trigger is None:
return [no_update]
return [not is_disabled]
@app.callback(
[
Output(test_div.id, "children"),
Output(trigger_div.id, "children")
],
[Input(test_button.id, "n_clicks")],
)
def button_click(n_clicks):
import logging
logging.getLogger("test").info(f"n_clicks: {n_clicks}. Sleeping...")
if n_clicks is None:
return [no_update, no_update]
import time
time.sleep(10)
return ["done", 1]
app.layout = html.Div([test_div, trigger_div, test_button])
The problem seems to be that dash wonāt execute the trigger_function while there is a callback running that has the trigger div as itās output. When I remove the trigger div as input to the trigger_function callback (they both only have the button as input), then it executes both simultaneously.
2020-06-17 19:13:49,458 INFO:n_clicks: 1. Sleeping...
2020-06-17 19:13:59,510 INFO:trigger! n_clicks: 1. trigger: 1, is_disabled: None
Note there is no trigger! n_clicks: 1, trigger: None
callback. Dash appears to have consolidated the n_clicks: 1, trigger: None
and n_clicks: 1, trigger: 1
into a single callback.