Google app engine 从应用程序引擎到云存储的异步请求

Google app engine 从应用程序引擎到云存储的异步请求,google-app-engine,google-cloud-storage,google-cloud-platform,Google App Engine,Google Cloud Storage,Google Cloud Platform,在我的应用程序引擎应用程序中,我使用它从云存储读取数据 当我从云存储读取多个文件时,是否有一个选项可以使此过程异步?扩展voscause所说的,您可以这样做。请记住,这只会在live server上起作用,因为不会在开发人员上创建访问令牌。如果要在开发人员上进行测试,请注释标题并将文件公开 urls = [] #List of url's with http:// scope = 'https://www.googleapis.com/auth/devstorage.full_control'

在我的应用程序引擎应用程序中,我使用它从云存储读取数据


当我从云存储读取多个文件时,是否有一个选项可以使此过程异步?

扩展voscause所说的,您可以这样做。请记住,这只会在live server上起作用,因为不会在开发人员上创建访问令牌。如果要在开发人员上进行测试,请注释标题并将文件公开

urls = [] #List of url's with http://

scope = 'https://www.googleapis.com/auth/devstorage.full_control'
token, _ = app_identity.get_access_token(scope)

rpcs = []
for url in urls:
    rpc = urlfetch.create_rpc()

    urlfetch.make_fetch_call(rpc, url,method=urlfetch.GET,
                             headers={'Authorization': 'OAuth %s' % token})
    rpcs.append(rpc)

# Finish all RPCs
for rpc in rpcs:
    self.response.write(rpc.get_result().content)
    self.response.write("</p>")
url=[]#带有http的url列表://
范围=https://www.googleapis.com/auth/devstorage.full_control'
令牌,\=应用\标识。获取\访问\令牌(作用域)
rpcs=[]
对于url中的url:
rpc=urlfetch.create_rpc()
调用(rpc,url,method=urlfetch.GET,
标头={'Authorization':'OAuth%s'%token})
rpcs.append(rpc)
#完成所有RPC
对于rpc中的rpc:
self.response.write(rpc.get_result().content)
self.response.write(“

”)
您必须将json API与异步urlfetch一起使用。谢谢!通过将dev_appserver配置为服务帐户,也可以在其上进行测试,如下所述: