Hi,
I am quite new to Dash, and I was previously using streamlit. When there are any errors in the code, while debugging, the server crashes rather than to just display the error, and it takes a LOT more time for me to restart the server after fixing it. And since I’m new, I do a lot of trial and error, and it is really cumbersome to wait till the server reloads and then crashes again due to an error. Is this a normal behaviour of dash or should I opt for a different configuration. I am currently running it as a python file in vs studio code
I also tried app.run_server(port="8052",debug=True, use_reloader = False)
but this doesn’t reflect any of the changes I am making.
Hello @ak3000,
Welcome to the community!
Changes that you make to the app during runtime should update, if you have use_reloader
not provided, as the default is True
.
Could you please provide a little more info about your setup?
Dash version, flask version, maybe just provide a pip freeze
and give the details here.
Typically, the sever wont completely crash unless you are running into a syntax error or an uninstalled library (this normally only happens when not in debug mode). I’d try taking out the use_reloader=False
and see if this issue goes away.
Ah my problem is syntax errors, but the server ends up crashing while I am making the edits, before I realize that I’ve made an error
What exactly takes a long time? Do you develop your tools locally? Personally, my apps start up in a few seconds on my laptop. Also, when working in Pycharm and when there is a SyntaxError, while the app is running, it will display the error in the run terminal in Pycharm.
Are you using very large Python libraries that take a long time to load, e.g. icevision, pytorch or other ML libraries?
It takes a long time for the server to become active after I type in the in python command. I work in VScode and it shows the syntax error in the terminal too, except the server has already died. I am trying to create a data viz dasboard, so there are plots and large dataframes it is using
Do you have autosaving turned on or something?
How long is “a long time” exactly? What happens when starting the Dash app, is that all python code is loaded. All libraries are imported, all top-level statements are executed. If you have big libraries, their load times might be the culprit here. Otherwise, do you perhaps have top level statements that take a long time to execute?
As for the SyntaxError, yes it kills the server because it encounters Python code that it cannot execute.
yes I do actually. But even without it, I have the same problem, cause I make a lot of errors while coding. I suppose I was hoping it to be like streamlit . Oh well I’ll just work around with this then. I found that running the app in jupyter notebook with the open as “tab” is much instant than running it in a .py, which takes 30 seconds each time i start the server
Hmm. That’s interesting. I’ve not used Streamlit, but I guess there might be some sort of error handling before it lets it run.
Well, most likely because in the Jupyter Notebook setting, it doesn’t need to execute all top-level statements or re-import all libraries when running your app. You must have some heavy weights in your code there.
Hello, I don’t know if you’re still having the same problem, but I was facing the same issue and found a solution that worked for me. I hope future readers can also find it helpful.
The issue is that even with debug_mode=True, the page you’re building only updates when you save the file (ctrl+s). In some code editors, there might be an option called Auto Save enabled, which causes the file to save during changes you’re making, even before you finish. This leads the server running your program to believe you’ve completed your edits, sometimes prematurely. I suggest disabling the Auto Save option in your code editor. I hope this helps.