重新加载单个模块在cherrypy? [英] Reload single module in cherrypy?

查看:51
本文介绍了重新加载单个模块在cherrypy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在独立的Cherrypy Web应用程序的单个模块上使用python reload命令(或类似命令)?我有一个基于CherryPy的Web应用程序,该应用程序经常处于持续使用状态.我会不时进行一次仅对一个模块产生影响的重要"更改.我希望能够立即重新加载该模块,而不会影响Web应用程序的其余部分.完全重新启动速度很快,但是,如果可能的话,我仍然希望避免几秒钟的停机时间.

Is it possible to use the python reload command (or similar) on a single module in a standalone cherrypy web app? I have a CherryPy based web application that often is under continual usage. From time to time I'll make an "important" change that only affects one module. I would like to be able to reload just that module immediately, without affecting the rest of the web application. A full restart is, admittedly, fast, however there are still several seconds of downtime that I would prefer to avoid if possible.

推荐答案

以一种理智的方式重新加载模块非常非常困难.它导致代码中的陈旧对象具有无法查询的状态和细微的错误的可能性.这不是您想做的事.

Reloading modules is very, very hard to do in a sane way. It leads to the potential of stale objects in your code with impossible-to-interrogate state and subtle bugs. It's not something you want to do.

真正的Web应用程序倾向于做的是让一台服务器保持在其应用程序的最前面,例如带有mod_proxy的Apache,作为反向代理.您启动新的应用程序服务器,更改反向代理的路由,然后杀死旧的应用程序服务器.

What real web applications tend to do is to have a server that stays alive in front of their application, such as Apache with mod_proxy, to serve as a reverse proxy. You start your new app server, change your reverse proxy's routing, and only then kill the old app server.

无停机时间.没有疯狂,不可破解的代码.

No downtime. No insane, undebuggable code.

这篇关于重新加载单个模块在cherrypy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆