App Engine 开发服务器在更改时不会重新加载代码
我正在开发一个将在 Google App Engine 上运行的 python 应用程序。我使用以下目录结构设置我的应用程序:
approot/
app.yaml
index.yaml
myapp.py
controllers/
some_controller.py
some_controller1.py
models/
views/
...etc...
我的问题是,当我进行更改时,开发服务器并不总是自动重新加载我的代码,即使 Google 的文档说它会。
它重新加载我的代码的唯一一次是当我所做的更改位于我的应用程序的顶级目录中时。子目录中的任何内容(例如控制器)都将被忽略。每次进行更改时,我都必须停止并启动服务器。
我发现这确实阻碍了我的开发进度,特别是因为没有重新启动按钮,您实际上必须先停止然后再启动。
有没有补救办法,或者我只是做错了?我真的很喜欢拥有一个组织良好的项目,并且不想将所有文件转储到顶级目录中。
I'm working on a python app that will run on top of Google App Engine. I setup my app up with the following directory structure:
approot/
app.yaml
index.yaml
myapp.py
controllers/
some_controller.py
some_controller1.py
models/
views/
...etc...
My problem is that the development server will not always automatically reload my code when I make changes even though Google's documentation says it will.
The only time it does reload my code is when the change I make is in the top level directory of my app. Anything in a subdirectory (e.g. controllers) is ignored. I have to stop and start the server every time a change is made.
I find this really impedes my progress in development, especially since there is no restart button, you actually have to hit stop and then start.
Is there a remedy for this or am I just doing it wrong? I really like having a well organized project and would rather not dump all my files in the top level directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
重新加载机制可能与默认导入机制和内置
__import__
函数相关。如果您(或您的框架)以某种其他巧妙的方式加载模块,重新加载器可能不会注意到。一种可能的解决方法是在myapp.py
模块中显式导入关键模块。The reload mechanism is likely tied to the default import mechanism and builtin
__import__
function. If you (or your framework) load your modules in some other, clever way, the reloader might not notice. A possible workaround is to explicitly import key modules in yourmyapp.py
module.仔细检查你是否已经安装了 pyobjc,
开发服务器会这样抱怨:
UserWarning: Detecting source codechanges not support because your Python version does not include PyObjC (http://pyobjc.sourceforge.net/)。请安装 PyObjC,或者如果不可行,请在 http: //code.google.com/p/appengine-devappserver2-experiment/issues/list。
double check that you have installed pyobjc
the dev server will complain like this:
UserWarning: Detecting source code changes is not supported because your Python version does not include PyObjC (http://pyobjc.sourceforge.net/). Please install PyObjC or, if that is not practical, file a bug at http://code.google.com/p/appengine-devappserver2-experiment/issues/list.