仅在启动新实例时使用DeadlineExceededError(使用webapp2)

时间:2013-09-29 05:18:46

标签: python google-app-engine webapp2

我得到一些奇怪的行为 - 当应用程序第一次启动一个新实例时,我得到一个DeadlineExceededError。当我在浏览器中点击刷新它工作得很好而且我尝试哪个页面并不重要。奇怪的是我可以很好地看到我所有的调试代码。实际上,我在调用self.response之前写入日志,它显示在控制台的日志中。这很难排除故障,因为我在开发环境中没有任何页面加载问题,并且回溯对我来说有点不透明:

E 2013-09-29 00:10:03.975
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 267, in Handle
    for chunk in result:
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 1286, in appstats_wsgi_wrapper
    end_recording(status)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 1410, in end_recording
    rec.save()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 654, in save
    key, len_part, len_full = self._save()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 678, in _save
    namespace=config.KEY_NAMESPACE)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 1008, in set_multi
    namespace=namespace)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 907, in _set_multi_with_policy
    status_dict = rpc.get_result()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
    return self.__get_result_hook(self)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 974, in __set_with_policy_hook
    rpc.check_success()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 578, in check_success
    self.__rpc.CheckSuccess()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
    raise self.exception
DeadlineExceededError

I 2013-09-29 00:10:03.988
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

我不确定如何调试这个,因为错误似乎是在我的代码已经运行之后。

编辑:我应该添加:

I 2013-09-29 00:09:06.919
  DEBUG: Writing output!
E 2013-09-29 00:10:03.975

您可以看到记录“写入输出”之间差不多有一分钟!就在调用self.response之前,当错误发生时。

1 个答案:

答案 0 :(得分:0)

Deadlineexceedederror 在app引擎中发生,如果对前端实例的任何请求在60秒内没有得到响应。因此,在您的情况下发生的情况必须是,当没有正在运行的实例且您的应用程序收到新的用户请求时,将启动一个新实例进行处理。这将导致整体response time = instance startup time like library loading and initial data access + the time for processing the user request,这会导致截止日期超出错误。然后,当您立即访问您的应用程序时,有一个已经在运行的实例,因此response time = the time for processing the user request并且您不会收到任何错误。

请检查handling deadlineexceedederror的建议方法,包括预热请求,这就像在实时用户请求到达之前保持实例准备就绪。

相关问题