Slow Requests on Local Flask Server

前端 未结 9 1951
无人共我
无人共我 2020-12-02 05:38

Just starting to play around with Flask on a local server and I\'m noticing the request/response times are way slower than I feel they should be.

Just a simple serve

相关标签:
9条回答
  • 2020-12-02 06:02

    I got this error when running on hosts other than localhost as well, so for some, different underlying problems may exhibit the same symptoms.

    I switched most of the things I've been using to Tornado, and anecdotally it's helped an amount. I've had a few slow page loads, but things seem generally more responsive. Also, very anecdotal, but I seem to notice that Flask alone will slow down over time, but Flask + Tornado less so. I imagine using Apache and mod_wsgi would make things even better, but Tornado's really simple to set up (see http://flask.pocoo.org/docs/deploying/others/).

    (Also, a related question: Flask app occasionally hanging)

    0 讨论(0)
  • 2020-12-02 06:03

    Add "threaded=True" as an argument to app.run(), as suggested here: http://arusahni.net/blog/2013/10/flask-multithreading.html

    For example: app.run(host="0.0.0.0", port=8080, threaded=True)

    The ipv6-disabling solution did not work for me, but this did.

    0 讨论(0)
  • 2020-12-02 06:07

    I had a different solution here. I just deleted all .pyc from the server's directory and started it again. By the way, localhost was already commented out in my hosts file (Windows 8).

    The server was freezing the whole time and now it works fine again.

    0 讨论(0)
提交回复
热议问题