I am trying to create a dashboard part of which runs some Julia code via juliacall. I have found that when the Julia code errors or prints then the Dash app hangs indefinitely. Is there a way around this?
A minimal example:
from dash import Dash, html, callback, Output, Input
import juliacall
app = Dash()
app.layout = html.Div(
children=[
html.Div(
id="box",
style={"background-color": "blue", "width": "500px", "height": "500px"},
),
html.Div(
html.Button(
id="button", n_clicks=0, style={"width": "100px", "height": "50px"}
),
),
],
style={"display": "flex"},
)
@callback(
Output("box", "style"),
Input("button", "n_clicks"),
prevent_initial_call=True,
)
def update_div(nclicks):
bc = "blue" if nclicks % 2 == 0 else "green"
if nclicks == 2:
juliacall.Main.seval('println("hi from julia")')
return {"background-color": bc, "width": "500px", "height": "500px"}
if __name__ == "__main__":
app.run(debug=True)