Open e-dervieux opened 3 years ago
Before finding this I asked the same question on stackexchange at https://stackoverflow.com/questions/77724451/how-to-run-a-dash-app-with-threading-and-with-debug-true maybe someone can help us there.
Try using the following
app.run_server(debug=True, use_reloader=False)
This works - thanks Sanskarbiswal
I would like to build an application using some kind of model-view-controller pattern with two main threads:
Here is a minimal working example of a typical code to perform such a task:
This scripts creates two
Thread
objects:DashThread
containing a Dash application which periodically updates the display of the global variablecounter
.CountingThread
, which periodically increases the global variablecounter
However, the code crashes with the error:
This seems to be related to the fact that Flask does not like to be launched in another thread that the main one, especially with the
debug=True
option, as documented here and there.I tried to adapt this answer yielding the following code:
without success. The issue disappears, however, if I remove the
debug=True
argument, leading:it works fine. Except of course, I am no longer able to use the debugging functionalities such as reload on save, etc.
Could this issue be solved by changing the way
Flask
is called inside the Dash libraries?Reproduced with Python 3.8, dash 1.20.0, flask 1.1.2.