NDB map(callback, produces_cursors=True)

我的梦境 提交于 2019-12-23 09:57:07

问题


The Google AppEngine NDB Documentation for map() states that:

"All query options keyword arguments are supported."

However, I have tried to use produces_cursors=True on map() and I'm not getting a cursor back.

map(callback, pass_batch_into_callback=None, merge_future=None, **q_options)

I'd like to use map() as I can set the callback to a tasklet.

https://developers.google.com/appengine/docs/python/ndb/queryclass#kwdargs_options

Edit - Providing code sample:

@ndb.tasklet
def callback(user):
    statistics = yield ndb.Key(Statistics, user.key.id()).get_async()
    raise ndb.Return(user, statistics)

result = User.query().map(callback, produces_cursors=True)

回答1:


The example seems to have a typo -- the correct flag is produce_cursors, not produces_cursors.

But cursors are only made available when you use an iterator, not with map(). Check out the async iterators example; it's a little bit of work but you can definitely use it to manually create a tasklet for each result.



来源:https://stackoverflow.com/questions/14125243/ndb-mapcallback-produces-cursors-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!