Reading URLs Asynchronously in Google App Engine

Go To StackoverFlow.com

0

Let's say I have the following code in Google App Engine:

from urllib import urlopen
...
data1 = urlopen(url2).read()
data2 = urlopen(url2).read()
...

To improve the latency, I would like to run these two requests to external URLs asynchronously. How can I do that? I know how to do it in normal Python using a thread pool, but Google App Engine does not seem to support multiple threads.

2012-04-04 21:04
by Petter


2

Did you read the docs? https://developers.google.com/appengine/docs/python/urlfetch/asynchronousrequests

2012-04-04 21:14
by Rick Mangi
Wow, I cannot believe I missed that document. :-) Thanks - Petter 2012-04-05 12:12


0

you should use ndb tasklets.

https://developers.google.com/appengine/docs/python/ndb/async#urlfetch

2012-04-04 21:22
by aschmid00
That's one way to do it, but not the only way - see Rick's response - Nick Johnson 2012-04-05 01:52
Ads