Run your flask app under a proper WSGI server capable of handling concurrent requests (perhaps gunicorn or uWSGI) and it’ll work. While developing, enable threads in the Flask-supplied server with:
but note that the Flask server is not recommended for production use. As of Flask 1.0,
threaded is enabled by default, and you’d want to use the
flask command on the command line, really, to run your app.
What happens is that using requests you are making a second request to your flask app, but since it is still busy processing the first, it won’t respond to this second request until it is done with that first request.
Incidentally, under Python 3 the socketserver implementation handles the disconnect more gracefully and continues to serve rather than crash.