2
votes

In my App Engine app I'm using Python Client for Google App Engine to read data from Cloud Storage.

When I'm reading multiple files from Cloud Storage, is there an option to make this process asynchronous?

1
You have to use the json API with async urlfetch.voscausa

1 Answers

1
votes

To extend what voscause said you can do something like this. Keep in mind this will only work on the live server as the access token won't be created on the dev. If you want to test on the dev comment out the headers and make the file public.

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>")