App Engine Python开发服务器+ Taskqueue +后端 [英] App Engine Python Development Server + Taskqueue + Backend
问题描述
我在本地开发服务器上使用GAE Python 2.7。我配置了后端
后端:
- 名称:worker
class:B1
选项:动态
我正在使用默认的任务队列。一切工作正常,后端和任务队列在SDK控制台中可见。此外,本地开发工作无误启动:
多进程设置完成:
远程API服务器[http:// localhost:9200]
App Instance [http:// localhost:9000]
后端实例:worker.0 [http:// localhost:9100]
后端平衡器:worker [http:/ / localhost:9199]
但是,如果我尝试通过任务解决后端问题, b
$ b
taskqueue.add(url ='/ xyz',method ='POST',target ='worker',params = {'a':' b'})
此错误提示:
错误在队列default中发送任务task1(Url:/ backend / languages / create_database /)时发生错误。作为任务错误处理。
Traceback(最近一次调用最后):
文件/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/taskqueue/taskqueue_stub .py,第1884行,在ExecuteTask
connection.endheaders()
文件/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py,第937行,在endheaders中
self._send_output(message_body)
文件/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py,第797行, in _send_output
self.send(msg)
文件/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py,第759行,发送
self.connect()
文件/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py,第740行,连接
self .timeout,self.source_address)
文件/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py,行553,在create_connection中
用于getaddrinfo(host,port,0,SOCK_STREAM)中的res:
gaierror:[Errno 8]节点名或服务器名已提供或未知
我正在使用'localhost',并且看不到任何失败原因。一些想法/解决方案?任何启动参数丢失或类似这样的事情?
谢谢 解决方案
这是 taskqueue.py
,它忽略了一个区分生产和开发环境。
在生产中,它通过连接目标
和 hostname
。
在开发过程中,这不起作用,并且在尝试解析 worker.localhost
address。
相反,它应该将任务主机设置为 ip:port
dev_appserver正在运行后端。
已有。
如果您希望收到有关更新的通知,欢迎随时将其列出。
I'm using GAE Python 2.7 with the local development server. I have configured a backend
backends:
- name: worker
class: B1
options: dynamic
and I'm using the default taskqueue. Everything works fine and the backend and taskqueue are visible at the SDK console. Also the local development work starts without any 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 address the backend via a task
taskqueue.add(url='/xyz', method='POST', target='worker', params={'a':'b'})
this error raises:
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'm using 'localhost' and can't see any reason why it fails. Some ideas / solutions? Any startup-parameter missing or somethin like that?
Thanks
It's a bug in taskqueue.py
, it misses a case to distinguish between production and the development environment.
In production, it does the right thing by concatenating the target
with the hostname
.
In development, that doesn't work and will produce the error you reported when trying to resolve worker.localhost
address.
Instead it should set the task host to the ip:port
dev_appserver is running the backend on.
There is already a bug in the public issue tracker that has been escalated to the engineering team.
Feel free to star it if you want to be notified about updates.
这篇关于App Engine Python开发服务器+ Taskqueue +后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!