4

我正在为 GAE 开发应用程序并尝试使用任务队列。目前,我只是通过 GAE 应用程序启动器在我的 Windows 机器上运行该东西,但是每当我尝试将任何东西排入队列时,开发“服务器”崩溃并且日志中充满了讨厌的输出。

taskqueue.add(url='/processWork', params={'key', myModel.key()})

我已经尝试在与其他工作的事务中运行它,所以我很确定工作已成功入队。

然而,不久之后开发服务器崩溃并且日志充满了这样的东西:

ERROR    2011-02-06 17:04:23,289
__init__.py:395] global name 'true' is not defined Traceback (most recent call last):   File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 517, in __call__
    handler.post(*groups)   File "C:\Projects\GAE\MyApp\main.py", line 114, in post
    activity.approved = true NameError: global name 'true' is not defined INFO     2011-02-06 17:04:23,309 dev_appserver.py:3317] "POST /processWork HTTP/1.1" 500 - WARNING  2011-02-06 17:04:23,309 taskqueue_stub.py:586] Task named "task1" on queue "default" failed with code 500; will retry in 30 seconds Traceback (most recent call last):   File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)   File "C:\Python27\lib\SocketServer.py", line 311, in process_request
    self.shutdown_request(request)   File "C:\Python27\lib\SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR) AttributeError: 'FakeConnection' object has no attribute 'shutdown' ERROR    2011-02-06 17:04:23,312 dev_appserver_main.py:494] Error encountered: Traceback (most recent call last):
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 488, in main
    http_server.serve_forever()
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3947, in serve_forever
    self.handle_request()
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3913, in handle_request
    self._handle_request_noblock()
    File "C:\Python27\lib\SocketServer.py", line 287, in _handle_request_noblock
    self.shutdown_request(request)
    File "C:\Python27\lib\SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR)   AttributeError: 'FakeConnection' object has no attribute 'shutdown'   Now terminating.
---------------------------------------- Exception happened during processing of request from ('0.1.0.2', 80)
---------------------------------------- 2011-02-06 09:04:23 (Process exited with code 1)

道歉 - 下面的回复发现了错字(真的,不是真的)。然而,当试图解决最初的问题时,这悄悄地出现了。如果我修正错字,排队的工作完成,但我的服务器仍然在日志中出现此错误:

INFO     2011-02-06 17:50:32,882 dev_appserver.py:3317] "POST /processWork HTTP/1.1" 200 -
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 311, in process_request
    self.shutdown_request(request)
  File "C:\Python27\lib\SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR)
AttributeError: 'FakeConnection' object has no attribute 'shutdown'
ERROR    2011-02-06 17:50:32,884 dev_appserver_main.py:494] Error encountered:
Traceback (most recent call last):

  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 488, in main
    http_server.serve_forever()

  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3947, in serve_forever
    self.handle_request()

  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3913, in handle_request
    self._handle_request_noblock()

  File "C:\Python27\lib\SocketServer.py", line 287, in _handle_request_noblock
    self.shutdown_request(request)

  File "C:\Python27\lib\SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR)

AttributeError: 'FakeConnection' object has no attribute 'shutdown'

Now terminating.
----------------------------------------
Exception happened during processing of request from ('0.1.0.2', 80)
----------------------------------------
2011-02-06 09:50:32 (Process exited with code 1)

如果我删除对 taskqueue.add 的调用,它可以正常工作(当然,没有排队的工作)。出了什么问题?

4

5 回答 5

8
File "C:\Python27\lib\SocketServer.py"

App Engine 使用 Python 2.5 运行,而您使用的是 Python 2.7。

于 2011-02-06T19:17:21.927 回答
5

看起来像一个简单的错字:

__init__.py:395] global name 'true' is not defined 
Traceback (most recent call last):   
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 517, in __call__
    handler.post(*groups)   
File "C:\Projects\GAE\MyApp\main.py", line 114, in post
    activity.approved = true NameError: global name 'true' is not defined

转到main.py第 395 行并更改

 activity.approved = true

 activity.approved = True

(大写“T”)

于 2011-02-06T17:37:21.330 回答
0

您实际上可以为此修补补丁(从 Python 2.7.1、pyOpenSSL 0.12 和 Werkzeug 0.6.2 开始需要):

### WARNING: Monkey patch in a fix to correct pyOpenSSL's
### incompatible ServerSocket implementation that accepts zero arguments
### for shutdown() instead of one. Fix is for:
### lib/python2.7/SocketServer.py:459's shutdown() call because that
### appears to be easier to quickly hack in versus patching
### pyOpenSSL. Again, don't use this for production, but it's great for
### testing.
def monkeyp_ssl_shutdown_request(self, request):
    try:
        request.shutdown()
    except socket.error:
        pass #some platforms may raise ENOTCONN here
    self.close_request(request)
from SocketServer import TCPServer
TCPServer.shutdown_request = monkeyp_ssl_shutdown_request

不漂亮,但是当有人关闭 SSL TCP 连接时,它比异常要好。

app.run(ssl_context='adhoc') # Now works
于 2011-05-23T18:58:55.767 回答
0

是的,这是因为您使用的是 2.7。 shutdown()2.6中添加。你必须运行2.5

于 2011-02-06T20:38:39.593 回答
0

另一个可能的原因是您未能导入中间件

from google.appengine.api import taskqueue
于 2013-05-05T20:01:48.527 回答