Google App Engine:随机错误" ImportError:无法导入名称节点"

时间:2012-09-06 18:06:30

标签: python google-app-engine jinja2

我最近去了我的App Engine网站,它运行得很好,没有错误,并得到了一个大丑陋的错误页面。在管理工具App Engine中记录了此错误:

2012-09-06 10:53:43.938
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 189, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 227, in _LoadHandler
    handler = __import__(path[0])
  File "/base/data/home/apps/s~myapp/1.361555922666090832/main.py", line 3, in <module>
    from controllers.routes import api_routes, web_routes, admin_routes
  File "/base/data/home/apps/s~myapp/1.361555922666090832/controllers/routes/api_routes.py", line 3, in <module>
    from ..api import api_obj_controller, api_app_controller, api_path_controller, api_user_controller
  File "/base/data/home/apps/s~myapp/1.361555922666090832/controllers/api/api_obj_controller.py", line 2, in <module>
    from ..handlers.api_handler import ApiRequestHandler
  File "/base/data/home/apps/s~myapp/1.361555922666090832/controllers/handlers/api_handler.py", line 2, in <module>
    from ..handlers.content_handler import BaseRequestHandler
  File "/base/data/home/apps/s~myapp/1.361555922666090832/controllers/handlers/content_handler.py", line 3, in <module>
    from webapp2_extras import jinja2
  File "/base/data/home/apps/s~myapp/1.361555922666090832/webapp2_extras/jinja2.py", line 15, in <module>
    import jinja2
  File "/base/python27_runtime/python27_lib/versions/third_party/jinja2-2.6/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/base/python27_runtime/python27_lib/versions/third_party/jinja2-2.6/jinja2/environment.py", line 13, in <module>
    from jinja2 import nodes
ImportError: cannot import name nodes
W 2012-09-06 10:53:43.967
After handling this request, the process that handled this request was found to have handled too many sequential errors, and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you are likely returning errors continously from your application.

因此它继续出现很多错误,但随后又开始工作而没有发布任何新代码。我的担忧显然是如何在将来阻止这种情况?为什么会这样?如果没有我部署任何代码修复,它如何才能纠正自己?这个错误让我感到紧张,因为它会随机发生在我的客户身上。

修改

此外,我收到的第一个错误是DeadlineExceededError错误,其中包含消息“此请求导致您的应用程序启动了新进程,从而导致您的应用程序代码首次加载。此请求因此,可能需要更长的时间并使用比典型的应用程序请求更多的CPU。“

所以从这条消息和蒂姆评论的内容完全有道理,但我该如何修复它以免再次发生?我可以做什么,所以DeadlineExceededError基本上不会错误输出整个站点,直到新的实例被启动? (如果我理解正确的话)

1 个答案:

答案 0 :(得分:2)

如果我理解正确,您在某些加载请求中看到了DeadlineExceededErrors,但处理该请求的实例未被杀死。

这可能是因为你有一些裸体,除了像以下的块:

try:
    do something
except:
    do other things

我认为,你的实例发生的事情是,其中一个这样的except子句捕获了DeadlineExceededErrors并且代码继续运行而不是抛出DeadlineExceededError。如果在导入jinja2期间抛出DeadlineExceededError,则jinja2模块可以保持半载状态。因此,实例一直生活在腐败的状态。

如果正确抛出DeadlineExceededError,则应该终止该实例,这样就不会有像您一样的损坏的实例。

这只是我的假设,让我知道是否可能出现这种情况。