With threaded=True
requests are each handled in a new thread. But if I set threaded true to my application it is showing unknown behavior.
This is my code.
from flask import Flask
from flask import jsonify
import time
app = Flask("proxapp")
import datetime
@app.route('/slow')
def slow():
start = datetime.datetime.now()
time.sleep(10)
return jsonify(start = start, end = datetime.datetime.now())
try:
app.run(threaded=True)
except Exception, e:
print repr(e)
I have opened two tabs in windows and tried to request same url in different tabs. second request is being served only after first request is being served. Second request is taking ~20 seconds to be served.
What is the problem with my code?