dash
dash copied to clipboard
[BUG] port forwarding does not work if use_reloader=True
Describe your context
I am used to developing my dash apps remotely where I use port forwarding from a linux to a win10 machine. When building a new one I realized the odd behaviour that omitting
use_reloader
leads to a never stop loading dash app on the local system but if I set use_reloader=False
it works as expected.
- results of
conda list | grep dash
below
dash 1.7.0 pypi_0 pypi
dash-bio 0.4.6 pypi_0 pypi
dash-bootstrap-components 0.8.1 pypi_0 pypi
dash-core-components 1.6.0 pypi_0 pypi
dash-cytoscape 0.1.1 pypi_0 pypi
dash-dangerously-set-inner-html 0.0.2 pypi_0 pypi
dash-daq 0.2.1 pypi_0 pypi
dash-html-components 1.0.2 pypi_0 pypi
dash-renderer 1.2.2 pypi_0 pypi
dash-table 4.5.1 pypi_0 pypi
-
I guess it is not system related but here it is
- Remote System CentOS Linux release 7.5.1804 (Core); Python 3.6.9
- Local System: Windows 10 (Browser: Brave,Chrome & Firefox)
Describe the bug
It is not really a bug since I already found a solution for it but if you want to reproduce it: Below does not work:
if __name__ == '__main__':
app.run_server(debug=True)
Below does work:
if __name__ == '__main__':
app.run_server(debug=True, use_reloader=False)
Port forwarding in both cases
Remote: python3 app.py & ssh -NfR 8050:localhost:8050 user@system
Local: python3 app.py & ssh -NfL 8050:localhost:8050 user@system
Expected behavior
Not sure what use_reloader
does explicitly but I just would expect that the port forwarding should not be affected by it? On the remote system's browser the app works despite not setting use_reloader=False
Screenshots I guess it would not help on the local system's browser there is just a spinning loading wheel in the taskbar and a completely white screen.
If this is kinda an expected behavior feel free to close this issue. I just wanted to share it because I was frustrated for over an hour why the new app just did not show up on my local system. Till code comparisons with my working app finally resolved it. So maybe this issue helps someone in the future why the port forwarding does not work.
Best, Ivo
I have the same issue. I don't know if you've found a way to get code reloading to work, but it has to do with the following (from dash documentation):
A caveat of Code Reloading is that your app code is run twice when starting: once to start the parent process and another time to run the child process that gets reloaded.
So if you have multiple instances of an ssh tunnel, your code will cause an error trying to open 2 tunnels using the same port at the same time.