I have a simple flask app, single page, upload html and then do some processing on it on the POST; at POST request; i am using beautifulsoup, pandas and usually it takes 5-10 sec to complete the task.
at the end i export the resultant dataframe to excel with pandas(with the update of the previous stored excel if present).
and on GET request i return the result of this dataframe.
Now issue is... app gives no response while those 5-10 sec.; even if i visit my app from another computer; it will show after the completion of those 5-10 sec.
It means if any user of this app has uploaded his file; then rest others have to wait till his job completes.
i have even added the below mentioned code in my app; but no improvement.
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
if __name__ == '__main__':
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(5657)
IOLoop.instance().start()
also my system and python version is as below.. .
>>> sys.version
'2.7.5 |Anaconda 1.8.0 (32-bit)| (default, Jul 1 2013, 12:41:55) [MSC v.1500 32 bit (Intel)]'
Note: i want to move it to python3.3, and wanted to remain on my windows 7 machine!!
Tornado is, typically, a single-threaded web server. If you write code specially for Tornado's asynchronous style you can process multiple requests concurrently, but in your case you aren't doing that; you're just using Tornado to serve requests with Flask, one at a time.
Remove Tornado and try using Flask's multithreaded option:
app.run(threaded=True)
If you're using WSGI's run_simple function just add the threaded=true
param.
Example:
run_simple('0.0.0.0', 9370, application, use_reloader=True, use_debugger=True, threaded=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With