Python Application Development Server + Taskqueue + Backend

I am using GAE Python 2.7 with a local development server. I set up the backend

backends: - name: worker class: B1 options: dynamic 

and I use the default task. Everything is working fine, and the backend and task are visible on the SDK console. Also, local development starts without errors:

 Multiprocess Setup Complete: Remote API Server [http://localhost:9200] App Instance [http://localhost:9000] Backend Instance: worker.0 [http://localhost:9100] Backend Balancer: worker [http://localhost:9199] 

BUT if I try to access the server through a task

 taskqueue.add(url='/xyz', method='POST', target='worker', params={'a':'b'}) 

this error occurs:

 ERROR An error occured while sending the task "task1" (Url: "/backend/languages/create_database/") in queue "default". Treating as a task error. Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/taskqueue/taskqueue_stub.py", line 1884, in ExecuteTask connection.endheaders() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 937, in endheaders self._send_output(message_body) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 797, in _send_output self.send(msg) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 759, in send self.connect() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 740, in connect self.timeout, self.source_address) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 553, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno 8] nodename nor servname provided, or not known 

I use "localhost" and see no reason why it fails. Some ideas / solutions? Any launch option missing or something like this?

thanks

+7
source share
2 answers

This is a bug in taskqueue.py , it skips the case to distinguish between production and development environments.

In production, he does the right thing by combining target with hostname .

In development, this does not work and will result in an error that you reported while trying to resolve the worker.localhost address.

Instead, it should set the task host to ip:port dev_appserver runs on the server.

There is already an error in the public issue tracking log, which has been expanded to an engineering team.

Feel free to receive notifications about updates.

+8
source

There is one workaround that helps me debug locally:

 if os.environ['SERVER_SOFTWARE'].startswith('Development'): taskqueue.add(url='/task', params={...}) else: taskqueue.add(url='/task', params={...}, target='backendservername') 

In this case, if we debug locally, we run the task in the usual task queue. If we put this code in App Engine, it will run the task using the server server.

+1
source

All Articles