问题描述
代码在SDK中可以正常工作,但在Google AppEngine中,它爆炸了:
文件./oauth2client /util.py第137行,位于位置打包程序
文件./googleapiclient/discovery.py,第197行,在build
文件./oauth2client/util.py,第137行,in locations_wrapper
文件./oauth2client/client.py,第563行,在new_request中
文件./httplib2/__init__.py,第1608行,请求
文件./httplib2 /__init__.py,第1350行,在_request
文件./httplib2/__init__.py,行1306,在_conn_request
文件/ base / data / home / runtimes / python27 / python27_dist / lib / python2.7 / python_std_lib / httplib.py,第1033行,在getresponse
中引发ResponseNotReady()
ResponseNotReady
只有GAE_USE_SOCKETS_HTTPLIB开启时才会发生这种情况。
发生这种情况是因为Google API库没有意识到这一点,并盲目地使用套接字连接到,这是不允许的。此外,实际的代码隐藏了真正的错误,在尝试创建套接字时拒绝了一个权限。
我没有意识到任何解决方法,除了禁用httplib的套接字或不使用提供的库,而是使用基于请求的库并安装使用urlfetch的适配器为这些域名。
The code will work just fine in the SDK, but on Google AppEngine, it explodes:
File "./oauth2client/util.py", line 137, in positional_wrapper
File "./googleapiclient/discovery.py", line 197, in build
File "./oauth2client/util.py", line 137, in positional_wrapper
File "./oauth2client/client.py", line 563, in new_request
File "./httplib2/__init__.py", line 1608, in request
File "./httplib2/__init__.py", line 1350, in _request
File "./httplib2/__init__.py", line 1306, in _conn_request
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/python_std_lib/httplib.py", line 1033, in getresponse
raise ResponseNotReady()
ResponseNotReady
This only happens when GAE_USE_SOCKETS_HTTPLIB is on.
This happens because the Google API library is not aware of this and blindly uses a socket to connect to https://www.googleapis.com, which is not allowed. Further, the actual code hides the real error, which a permission denied on trying to create a socket.
I'm not aware of any workaround, except disabling sockets for httplib, or not using the provided libraries, but using a requests based one and installing an adapter that uses urlfetch for these domains.
这篇关于为什么在GAE_USE_SOCKETS_HTTPLIB的appengine中使用Google API Python客户端会导致ResponseNotReady的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!