概述
map()的Google AppEngine NDB文档指出:
“All query options keyword arguments are supported.”
但是,我试图在map()上使用produce_cursors = True,而我没有得到光标.
map(callback,pass_batch_into_callback=None,merge_future=None,**q_options)
我想使用map(),因为我可以将回调设置为tasklet.
https://developers.google.com/appengine/docs/python/ndb/queryclass#kwdargs_options
编辑 – 提供代码示例:
@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)
但是,只有在使用迭代器时才使用游标,而不使用map().查看异步迭代器示例;这是一些工作,但你绝对可以使用它为每个结果手动创建一个tasklet.
总结
以上是编程之家为你收集整理的python – NDB映射(回调,produce_cursors = True)全部内容,希望文章能够帮你解决python – NDB映射(回调,produce_cursors = True)所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧