加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – NDB映射(回调,produce_cursors = True)

发布时间:2020-12-16 21:55:50 所属栏目:Python 来源:网络整理
导读: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

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)
最佳答案
这个例子似乎有一个错字 – 正确的标志是produce_cursors,而不是produce_cursors.

但是,只有在使用迭代器时才使用游标,而不使用map().查看异步迭代器示例;这是一些工作,但你绝对可以使用它为每个结果手动创建一个tasklet.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读