You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
DashThread containing a Dash application which periodically updates the display of the global variable counter.
CountingThread, which periodically increases the global variable counter
However, the code crashes with the error:
Traceback (most recent call last):
File "/Users/XXX/anaconda3/envs/multiproc_env/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/Users/XXX/OneDrive - Biosency/Python/05_a_atmos/src/test_c.py", line 31, in run
app.run_server(dev_tools_silence_routes_logging=True, debug=True)
File "/Users/XXX/anaconda3/envs/multiproc_env/lib/python3.8/site-packages/dash/dash.py", line 1718, in run_server
self.server.run(host=host, port=port, debug=debug, **flask_run_options)
File "/Users/XXX/anaconda3/envs/multiproc_env/lib/python3.8/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/Users/XXX/anaconda3/envs/multiproc_env/lib/python3.8/site-packages/werkzeug/serving.py", line 1050, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "/Users/XXX/anaconda3/envs/multiproc_env/lib/python3.8/site-packages/werkzeug/_reloader.py", line 330, in run_with_reloader
signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
File "/Users/XXX/anaconda3/envs/multiproc_env/lib/python3.8/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
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:
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.
The text was updated successfully, but these errors were encountered: