1

我正在尝试将 Python 应用从 App Engine 标准环境移植到 App Engine 灵活环境。按照App Engine 文档中的说明,我将 app.yaml 文件更改为使用“python-compat”模式,如下所示:

service: default
runtime: python-compat
api_version: 1
vm: true
threadsafe: true
instance_class: F2

inbound_services:
- warmup

builtins:
- remote_api: on

env_variables:
  GCLOUD_PROJECT: the-name-of-my-project

部署后,任何从应用程序调用数据存储的尝试(使用 NDB api)都会导致以下引用(截断):

File "/env/local/lib/python2.7/site-packages/google/appengine/datastore/datastore_rpc.py" in check_rpc_success
  1371.       rpc.check_success()
File "/env/local/lib/python2.7/site-packages/google/appengine/api/apiproxy_stub_map.py" in check_success
  579.       self.__rpc.CheckSuccess()
File "/env/local/lib/python2.7/site-packages/google/appengine/ext/vmruntime/vmstub.py" in _WaitImpl
  312.         raise self._ErrorException(*_DEFAULT_EXCEPTION)

Exception Type: RPCFailedError at /volume-list/
Exception Value: The remote RPC to the application server failed for call datastore_v3.RunQuery().

知道问题是什么吗?据我所知,App Engine 文档没有提供使用 python-compat 运行时设置 NDB 的特殊说明。

4

1 回答 1

1

我这周刚遇到这个错误,在调试它并使用 App Engine 支持后,找到了答案。

有关更多详细信息,请参见我的SO 答案,或者只需将以下代码添加到appengine_config.py

try:
    import appengine.ext.vmruntime.vmstub as vmstub
except ImportError:
    pass
else:
    if isinstance(vmstub.DEFAULT_TIMEOUT, (int, long)):
        # Newer requests libraries do not accept integers as header values. 
        # Be sure to convert the header value before sending. 
        # See Support Case ID 11235929.
        vmstub.DEFAULT_TIMEOUT = bytes(vmstub.DEFAULT_TIMEOUT)
于 2016-10-22T23:41:19.453 回答