Reputation: 1495
I am working on a web app using Flask in PyCharm.
I have not had any problem so far, but all of its sudden something changes and it is making the work really difficult.
First thing this the app does is connecting to a network folder and creates a map of all the files and directories in the folder (a network shared folder in a windows computer ). It used to take about five seconds to do that, and it started running the app without any problem.
However, I do not know what happened (I think I did not do anything), but all of its sudden the file mapping takes about three minutes and debugger tries to connect again and start the app again. It does the files mapping again also. After doing this the app start running. But, if I change a line in my code, it does this cycle again.
Since the file mapping became really slow, I checked the computer that hosting the files, but it did not show any sign of problem.
I am really confused because this started happening all of its sudden.
Below is the message I am getting in the console window if PyCharm.
pydev debugger: process 3412 is connecting
Connected to pydev debugger (build 163.15188.4)
* Restarting with stat
pydev debugger: process 2248 is connecting
* Debugger is active!
* Debugger PIN: 288-833-753
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
Did anybody had similar experience? Could you please share your insight of this problem?
Thanks
Upvotes: 1
Views: 292
Reputation: 4699
I would try running with debug=False
or use_reloader
to prevent flask from restarting after detecting a change in your files and see if anything changes.
More info about the reloaded here: How to stop Flask from initialising twice in Debug Mode?
The slowness in the startup could be attributed to any long running tasks in your app initialization code.
You would need to include more code or profile the code yourself to troubleshoot that.
If you are reading or writing from/to a network location IO might be your bottleneck.
Lastly, I recently went through an effort of troubleshooting/optimizing a flask app startup time - maybe something there could be useful to you: Slow Flask Development Server Initialization Profiling: `WaitForSingleObject`
Upvotes: 1