在ndb tasklet中使用images.get_serving_url_async()是否安全?

Pas*_*que 6 google-app-engine app-engine-ndb

NDB tasklet yield是一种做异步/并行代码的好方法.但是,从文档中可以清楚地看出,这种机制可以安全地与非ndb异步函数一起使用,例如images.get_serving_url_async().

NDB异步操作文档页面有大约使用的NDB上下文的自己的版本一个很小的部分urlfetch_async(),其中规定(重点煤矿):

URL Fetch服务具有自己的异步请求API.它很好,但并不总是很容易使用NDB tasklet.

我不清楚为什么"并不总是很容易使用NDB tasklets",这让我想知道相同的陈述是否适用images.get_serving_url_async().

所以我的问题是:如果我这样做,我会遇到麻烦吗?

@ndb.tasklet
def foo():
    url = yield images.get_serving_url_async(image_key)
Run Code Online (Sandbox Code Playgroud)

Gui*_*sum 4

没事。该yield将等待RPC并允许其他tasklet在等待时运行。关于 urlfetch 的评论只是关于它笨拙的 API。