def update(id, add, delay=0): entity = yield SomeKind.get_by_id_async(id) foo = entity.foo foo += add yield ndb.sleep(delay) entity.foo = foo yield entity.put_async()
def callback(): transaction = ndb.get_context().transaction yield ndb.sleep(delay) assert ndb.get_context().transaction == transaction raise ndb.Return(transaction)