Earlier I was using Waitress. Now I'm using Gevent to run my Flask app that has only one API
from flask import Flask, request, jsonify
import documentUtil
from gevent.pywsgi import WSGIServer
app = Flask(__name__)
@app.route('/post-document-string', methods=['POST'])
def parse_data():
req_data = request.get_json(force=True)
text = req_data['text']
result = documentUtil.parse(text)
return jsonify(keywords = result)
if __name__=='__main__':
http_server = WSGIServer(('127.0.0.1', 8000), app)
http_server.serve_forever()
This works fine. But the API is not asynchronous. If from front-end, I fire the same API twice at the same time, the second call waits for the first one to give response first.
What is wrong here ? How can I make it asynchronous ?
from Using Gevent in flask: API is not asynchronous
No comments:
Post a Comment