Reputation: 9699
I have a relatively simple script I use to run map jobs over my data, and I'd like it to run a faster by using gevent to make reads from the datastore non-blocking.
I tried adding gevent.monkey.patch_socket()
to the top of remote_api_shell.py
, but after I log in, it throws a urllib2.URLError
(traceback).
I'm new to both GAE and gevent. Is there an easier way to accomplish what I'm trying to do? Could someone point me in the right direction to get this working?
Upvotes: 0
Views: 236
Reputation: 10164
ndb
:You can use ndb
with *_async
datastore operations:
https://developers.google.com/appengine/docs/python/ndb/async
For example, to retrieve a list of elements by key:
ndb.get_multi_async(list_of_keys)
The great thing with ndb
is that every datastore operation on keys or entities has an async equivalent.
db
:You can use the Async Datastore API.
For example, to retrieve a list of elements by key:
from google.appengine.ext import db
db.get_async(list_of_keys)
Where list_of_keys
contains elements that are either strings, instances of google.appengine.api.datastore_types.Key
, or instances of google.appengine.api.datastore.Entity
.
Similarly you can use db.put_async
on lists of entities and db.delete_async
on lists similar to those for db.get_async
.
Upvotes: 1