1

我遇到了一些奇怪的行为——当应用程序第一次启动一个新实例时,我得到一个 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

您可以看到在记录“Writing output!”之间有将近一分钟的时间。就在调用 self.response 之前以及发生错误时。

4

1 回答 1

0

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

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

于 2013-09-29T08:32:44.380 回答