rocketboy2000
rocketboy2000

Reputation: 119

GAE NDB example useage of Future.wait_all()

sorry for my ignorance but my expectation is that this would work:

from google.appengine.ext import ndb
from models import myModels

delete_futures = []
delete_futures.append(ndb.delete_multi_async(myModels.Kind1.query().fetch(999999, keys_only=True)))
delete_futures.append(ndb.delete_multi_async(myModels.Kind2.query().fetch(999999, keys_only=True)))

ndb.Future.wait_all(delete_futures)

but it throws "TypeError: list objects are unhashable".

Upvotes: 1

Views: 1116

Answers (2)

Greg
Greg

Reputation: 10360

each call to delete_multi_async returns a list of futures, so your delete_futures list is a list of lists. Change your appends to extend and it should work

Upvotes: 1

Paul Collingwood
Paul Collingwood

Reputation: 9116

perhaps use .extend to create a single list rather then a list of lists?

Wait until all Futures in the passed list are done.

Not expecting your passed list of lists maybe.

delete_futures = []
delete_futures.extend(ndb.delete_multi_async(myModels.Kind1.query().fetch(999999,          keys_only=True)))
delete_futures.extend(ndb.delete_multi_async(myModels.Kind2.query().fetch(999999, keys_only=True)))

https://developers.google.com/appengine/docs/python/ndb/futureclass#Future_wait_all

Upvotes: 4

Related Questions