1
votes

I am attempting to port a Python app from App Engine Standard Environment to App Engine Flexible environment. Following the directions in the App Engine documentation, I've changed my app.yaml file to use "python-compat" mode, as shown:

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

When deployed, any attempts to call into the datastore from the application (using the NDB api) results in the following trackback (truncated):

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().

Any idea what the problem is? So far as I can tell, the App Engine documentation gives no special instruction for setting up NDB with the python-compat run-time.

1

1 Answers

1
votes

I just ran into this bug this week, and after debugging it and working with App Engine support, found the answer.

See my SO answer here for more details, or just add the following code to 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)