I am using Cherrypy
to create an Application that takes user input, manipulates that data. Basically, executes a time taking script . And then when all that is done, it displays a new page. My problem is that by the time my script finishes execution, browser loses connection and displays The page at myexample.com isn't working
or No data received
. Although the whole script doesn't take more than a minute to execute. Any leads on how to go about would be appreciated.
Cherrypy is a multi-threaded python web server. Due to the python GIL you cannot run a time taking script when answering a request because it will cause Cherrypy to be unresponsive to any new user, meanwhile your script is running.
You need to run your time taking script in a separated python process. The best way to do this is using a queue manager like Celery or RQ .
Check this answer to have a detailed example on how to do this with Cherrypy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.