谷歌数据存储(ndb)与geven

2024-06-28 15:20:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将基于gevent的服务器与远程数据存储api一起使用,偶尔也会得到

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 884, in handle_one_response
    self.run_application()
  File "/home/abhinavabcd_gmail_com/samosa-scripts/samosa_messaging_framework/geventwebsocket/handler.py", line 76, in run_ap
plication
    self.run_websocket()
  File "/home/abhinavabcd_gmail_com/samosa-scripts/samosa_messaging_framework/geventwebsocket/handler.py", line 52, in run_we
bsocket
    self.application(self.environ, lambda s, h, e=None: [])
  File "server.py", line 478, in __call__
    current_app.handle()
  File "/home/abhinavabcd_gmail_com/samosa-scripts/samosa_messaging_framework/geventwebsocket/resource.py", line 23, in handl
e
    self.protocol.on_close()
  File "/home/abhinavabcd_gmail_com/samosa-scripts/samosa_messaging_framework/geventwebsocket/protocols/base.py", line 14, in
 on_close
    self.app.on_close(reason)
  File "server.py", line 520, in on_close
    current_node.destroy_connection(self.ws)
  File "server.py", line 428, in destroy_connection
    db.remove_connection(conn.connection_id)
  File "/home/abhinavabcd_gmail_com/samosa-scripts/samosa_messaging_framework/database_ndb.py", line 141, in remove_connectio
n
    key.delete()

 File "/home/abhinavabcd_gmail_com/google_appengine/google/appengine/ext/ndb/model.py", line 3451, in _put
    return self._put_async(**ctx_options).get_result()
  File "/home/abhinavabcd_gmail_com/google_appengine/google/appengine/ext/ndb/tasklets.py", line 383, in get_result
    self.check_success()
  File "/home/abhinavabcd_gmail_com/google_appengine/google/appengine/ext/ndb/tasklets.py", line 378, in check_success
    self.wait()
  File "/home/abhinavabcd_gmail_com/google_appengine/google/appengine/ext/ndb/tasklets.py", line 362, in wait
    if not ev.run1():
  File "/home/abhinavabcd_gmail_com/google_appengine/google/appengine/ext/ndb/eventloop.py", line 253, in run1
    delay = self.run0()
  File "/home/abhinavabcd_gmail_com/google_appengine/google/appengine/ext/ndb/eventloop.py", line 238, in run0
    (rpc, self.rpcs))
RuntimeError: rpc <google.appengine.api.apiproxy_stub_map.UserRPC object at 0x7fb46e754a90> was not given to wait_any as a ch
oice {<google.appengine.api.apiproxy_stub_map.UserRPC object at 0x7fb46e779f90>: (<bound method Future._on_rpc_completion of 
<Future 7fb46e756f10 created by run_queue(context.py:185) for tasklet _memcache_set_tasklet(context.py:1111); pending>>, (<go
ogle.appengine.api.apiproxy_stub_map.UserRPC object at 0x7fb46e779f90>, '', <google.appengine.datastore.datastore_rpc.Connect
ion object at 0x7fb46e874250>, <generator object _memcache_set_tasklet at 0x7fb46e79b9b0>), {}), <google.appengine.api.apipro
xy_stub_map.UserRPC object at 0x7fb46e75c690>: (<bound method Future._on_rpc_completion of <Future 7fb46e7c8950 created by ru
n_queue(context.py:185) for tasklet _memcache_set_tasklet(context.py:1111); pending>>, (<google.appengine.api.apiproxy_stub_m
ap.UserRPC object at 0x7fb46e75c690>, '', <google.appengine.datastore.datastore_rpc.Connection object at 0x7fb46e7c8ad0>, <ge
nerator object _memcache_set_tasklet at 0x7fb46e6f3640>), {})}


# monkey patched already 
try:
    import dev_appserver
    dev_appserver.fix_sys_path()  
except ImportError:
    print('Please make sure the App Engine SDK is in your PYTHONPATH.')
    raise

email = '----SERVICE_ACCOUNT_EMAIL-------'

from google.appengine.ext.remote_api import remote_api_stub remote_api_stub.ConfigureRemoteApiForOAuth(
     '{}.appspot.com'.format("XXXPROJECT_IDXXX"),
     '/_ah/remote_api' ,
     service_account=email, 
     key_file_path='KEY---1927925e9abc.p12')


import config
from google.appengine.ext import ndb 
from lru_cache import LRUCache 

偶尔会发生这种情况,包括数据存储写入操作、put和delete。 任何能理解/解决这个问题的建议都值得赞赏。你知道吗


Tags: inpyselfcomapihomeobjectgoogle