Reputation: 2163
Recently I'm developing a Flask website/api app to Windows Server and saw some weird issue going on.
When someone make a request to a url, occasionally(like 3-4 out of 10 times) it will hang. All I need to do to make that request come through is going to the command line where I fire up the Flask server, and send an interrupt signal. (I'm on windows, so basically "Ctrl + C"). I've googled for a while, but I believe none of the solutions applies. Here's what I've tried:
threaded=true
in app.run()
as suggested here didn't work.requests
library and still see the server hangs. I have pretty much same setup on my local machine(win7 64bit) and everything just works fine. (The server that has issue is Windows Server 2012)
I'd love to share some code, but I highly doubt it would be code issue, since it works perfectly fine locally.
Has anyone experienced the same thing before?
Upvotes: 10
Views: 5924
Reputation: 11515
Everything said here is true - when you put it together the right way ;-)
flask
CLI tool.flask
cli program AND the script had threaded=true
- which will only apply when you call the script directly (no flask
CLI). So This is a correct answer - but for a different reason.flask
CLI. This can be done by simply adding --with-threads
to the flash
command.In summary - two correct methods will work:
threaded=true
in app.run()
and run your script directly--with-threads
to the flask
CLI program and run that way.Upvotes: 0
Reputation: 2163
After checking with colleague(guess I should've done it earlier..), it seems that the command line tool itself is the issue...(can't believe it). After set it up to run as a Windows Scheduled Task, made a few hundreds requests and experienced no issue at all.
Upvotes: 7