Google App Engine task queues are a nasty crash

I am developing an application for GAE and trying to use Task Queues. Currently, I have just working on my Windows box through the GAE App Launcher, but whenever I try to insert something, the development server crashes and the log is full of unpleasant output.

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

I tried to run this in a transaction with a different job, so I'm sure the job completed successfully.

However, shortly after this, the development server crashes, and the log is full of such things:

 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 - the answer below noticed a typo (true, not True). However, this crept in when trying to solve the original problem. If I correct the typo, the queue is finished, but my server still crashes 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", 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) 

If I remove the call to taskqueue.add, it works fine (without queuing, of course). What is going wrong?

+4
source share
5 answers
 File "C:\Python27\lib\SocketServer.py" 

App Engine works with Python 2.5, and you are using Python 2.7.

+8
source

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 line main.py line 395 and change

  activity.approved = true 

to

  activity.approved = true 

(uppercase "T")

+5
source

Yes, this is because you are using 2.7. shutdown() was added in 2.6 . You need to run 2.5 .

0
source

In fact, you can use the monkey patch in the fix for this (required from 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 shutdown() call because that ### appears to be easier to quickly hack in versus patching ### pyOpenSSL. Again, don't use this for production, but it 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 really, but it's better than an exception when someone closes the SSL TCP connection.

 app.run(ssl_context='adhoc') # Now works 
0
source

Another possible reason is that you are not importing midule

 from google.appengine.api import taskqueue 
0
source

Source: https://habr.com/ru/post/1338642/


All Articles