我喜欢Google App Engine开发环境的一个方面是,每次我更改任何python源文件,其他静态文件甚至配置文件时,我都不必重新启动服务器.它已经破坏了我,当我使用其他服务器环境(tornadoweb,web.py,node.js)时,我忘记重新启动服务器.
任何人都可以解释GAE是如何做到的吗?使其他服务器(至少基于python)实现同样的事情有多难?
dev_appserver.py您可以查看(链接)的源代码。看起来ModuleManager会复制sys.modules并监视每个模块以根据时间跟踪更改:
class ModuleManager(object):
"""Manages loaded modules in the runtime.
Responsible for monitoring and reporting about file modification times.
Modules can be loaded from source or precompiled byte-code files. When a
file has source code, the ModuleManager monitors the modification time of
the source file even if the module itself is loaded from byte-code.
"""
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
507 次 |
| 最近记录: |