I use backend to write multiple objects with ndb.put_multi(list_of_entities) .
The problem I am facing is that after that, if I make a request, I will not get any results. If I set a sleep timer, for example, for 1 second, I can read the objects that I just wrote.
So for example:
class Picture(ndb.Expando): pass class Favourite(ndb.Expando): user_id = ndb.StringProperty(required=True) pass
At first it was assumed that the problem was related to caching. But
Read NDB object operations for multiple keys or objects :
Extended note: these methods correctly interact with context and caching; they do not correspond directly to specific RPC calls.
Reading NDB Caching
In-context cache
The internal content cache is stored only for one incoming HTTP request and is "visible" only for the code that processes this request. It is fast; This cache lives in memory. When an NDB function writes to the Datastore, it also writes to the cache context. When the NDB function reads an object, it checks the cache context first. If an object is found there, no interaction with the data warehouse takes place.
Queries do not look up values in any cache. However, the query results are written back to the cache if the cache policy says so (but never in Memcache).
I'm here. Everything seems to be in order. Even if the request from the console I get the correct amount, but never on the same handler, no matter what function, etc.
The only thing I noticed is that when you put wait time.sleep(1) , I get the correct results. So this is due to the fact that ndb.put_multi may not run synchronously or not. So confused ....