python
flask with gevent monkey patch all
시간을 거스르는자
2017. 7. 26. 15:30
Problem:
- content length mismatched(ERR_CONTENT_LENGTH_MISMATCH)
- response string truncated (cut off)
If you are using flask with gevent monkey patch all and you got such a problem above,
than you should use gevent wsgi instead of flask app.run
For example..
from gevent import monkey monkey.patch_all() from flask import Flask from gevent import wsgi app = Flask(__name__) @app.route('/') def index(): return 'Hello World' server = wsgi.WSGIServer(('127.0.0.1', 5000), app) server.serve_forever() |
reason:
flask is not for aysnc future model, so if you want to use asynchronous for http or any socket use, than you should use gevent wsgi