1

我使用的是 SDK 1.9.9 版,但我遇到了开发服务器问题。我有一个带有 1 个实例的手动缩放模块。我创建了一个webapp2.RequestHandlerfor /_ah/start。在那个处理程序中,我启动了一个后台线程。当我在 devserver 中运行我的应用程序时,_ah/start处理程序返回 200,但/_ah/background会在一段时间内随机返回 500 个错误。一段时间后(通常是一两分钟,但有时更多),500 错误停止,但每隔几个小时会随机再次出现。似乎每次我打开一个新的浏览器选项卡(Chrome)时,我都会收到同样的错误。有谁知道这可能是什么原因造成的?

这是RequestHandlerfor /_ah/start

class StartupHandler(webapp2.RequestHandler):
    def get(self):
        runtime.set_shutdown_hook(shutdown_hook)

        global foo
        if foo is None:
            foo = Foo()

        background_thread.start_new_background_thread(do_foo, [])

        self.response.http_status_message(200)

这是500错误:

ERROR    2014-08-18 07:39:36,256 module.py:717] Request to '/_ah/background' failed
Traceback (most recent call last):
  File "\appengine\tools\devappserver2\module.py", line 694, in _handle_request
    environ, wrapped_start_response)
  File "\appengine\tools\devappserver2\request_rewriter.py", line 311, in _rewriter_middleware
     response_body = iter(application(environ, wrapped_start_response))
  File "\appengine\tools\devappserver2\module.py", line 1672, in _handle_script_request
    request_type)
  File "\appengine\tools\devappserver2\module.py", line 1624, in _handle_instance_request
    request_id, request_type)
  File "\appengine\tools\devappserver2\instance.py", line 382, in handle
    request_type))
  File "\appengine\tools\devappserver2\http_proxy.py", line 190, in handle
    response = connection.getresponse()
  File "E:\Programing\Python27\lib\httplib.py", line 1030, in getresponse
    response.begin()
  File "E:\Programing\Python27\lib\httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "E:\Programing\Python27\lib\httplib.py", line 365, in _read_status
    line = self.fp.readline()
  File "E:\Programing\Python27\lib\socket.py", line 430, in readline
    data = recv(1)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
INFO     2014-08-18 07:39:36,257 module.py:1890] Waiting for instances to restart
INFO     2014-08-18 07:39:36,262 module.py:642] lease: "GET /_ah/background HTTP/1.1" 500 -
4

2 回答 2

2

好吧,这可能不是答案,但是完成分配给后端的特定任务需要多长时间?似乎是并发问题

于 2014-08-18T04:54:58.913 回答
1

看起来问题(据我目前所知)是我正在使用 PyCharm,它在进入或退出窗口时同步项目的文件。即使没有更改,这也会重写项目文件,这会导致开发服务器重新启动所有实例,从而导致 500 错误。

有关 PyCharm 同步的更多信息

PyCharm 的问题链接

于 2014-08-20T01:53:16.267 回答