App Engine 开发服务器在更改时不会重新加载代码

App Engine Development Server Does Not Reload Code When Changed(App Engine 开发服务器在更改时不会重新加载代码)
本文介绍了App Engine 开发服务器在更改时不会重新加载代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在开发一个将在 Google App Engine 之上运行的 python 应用程序.我使用以下目录结构设置我的应用程序:

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...

我的问题是,当我进行更改时,开发服务器不会总是自动重新加载我的代码,即使 Google 的文档说它会这样做.

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.

推荐答案

重载机制可能与默认导入机制和内置 __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 your myapp.py module.

这篇关于App Engine 开发服务器在更改时不会重新加载代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

patching a class yields quot;AttributeError: Mock object has no attributequot; when accessing instance attributes(修补类会产生“AttributeError:Mock object has no attribute;访问实例属性时)
How to mock lt;ModelClassgt;.query.filter_by() in Flask-SqlAlchemy(如何在 Flask-SqlAlchemy 中模拟 lt;ModelClassgt;.query.filter_by())
FTPLIB error socket.gaierror: [Errno 8] nodename nor servname provided, or not known(FTPLIB 错误 socket.gaierror: [Errno 8] nodename nor servname provided, or not known)
Weird numpy.sum behavior when adding zeros(添加零时奇怪的 numpy.sum 行为)
Why does the #39;int#39; object is not callable error occur when using the sum() function?(为什么在使用 sum() 函数时会出现 int object is not callable 错误?)
How to sum in pandas by unique index in several columns?(如何通过几列中的唯一索引对 pandas 求和?)