[英]Run time taking script behind Cherrypy
I am using Cherrypy
to create an Application that takes user input, manipulates that data. 我正在使用
Cherrypy
创建一个需要用户输入,操纵该数据的应用程序。 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
. 我的问题是,当我的脚本执行完毕时,浏览器将失去连接并显示
The page at myexample.com isn't working
或未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. Cherrypy是一个多线程python Web服务器。 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.
由于使用了python GIL,因此您无法在回答请求时运行耗时的脚本 ,因为这会导致Cherrypy在运行脚本时对任何新用户无响应。
You need to run your time taking script in a separated python process. 您需要在单独的python进程中运行花费时间的脚本 。 The best way to do this is using a queue manager like Celery or RQ .
最好的方法是使用Celery或RQ之类的队列管理器。
Check this answer to have a detailed example on how to do this with Cherrypy. 检查此答案以获取有关如何使用Cherrypy的详细示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.