Google App Engine Task Queues - nasty failure
I'm developing an app for GAE and trying to use Task Queues. At present, I just have the thing running on my Windows box through GAE App Launcher but whenever I try to enqueue anything, the development 'server' crashes over and the log is full of nasty output.
taskqueue.add(url='/processWork', params={'key', myModel.key()})
I've tried running this in a transaction with other work so I'm pretty sure the work is being successfully enqueued.
However, shortly afterwards the development server crashes and the log is full of stuff like this:
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)
Apologies - a reply below spotted the typo (true, not True). However, this crept in when trying to resolve the original problem though. If I fix the typo, the queued work completes but my server still falls over with this error in the log:
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", li开发者_StackOverflowne 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)
If I remove the call to taskqueue.add it works fine (without the queued work, of course). What is going wrong?
File "C:\Python27\lib\SocketServer.py"
App Engine runs with Python 2.5 and you are using Python 2.7.
Looks like a simple typo:
__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
Go to main.py
line 395 and change
activity.approved = true
to
activity.approved = True
(uppercase "T")
Yeah, it's because you're using 2.7. shutdown()
was added in 2.6. You've got to run 2.5.
You can actually monkey patch in a fix in for this (required as of Python 2.7.1, pyOpenSSL 0.12 and 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
Not pretty, but it's better than an exception when someone closes an SSL TCP connection.
app.run(ssl_context='adhoc') # Now works
Another possible reason is that you fail to import the midule
from google.appengine.api import taskqueue
精彩评论