Created
September 17, 2015 02:30
-
-
Save swshan/931832a37906521a4d47 to your computer and use it in GitHub Desktop.
Python exercises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from eventlet.green import urllib2 | |
urls=[ "http://www.douban.com", | |
"http://weibo.com", | |
] | |
def fetch(url): | |
return url, urllib2.urlopen(url).info() | |
pool =eventlet.GreenPool(4) | |
for url, body in pool.imap(fetch,urls): | |
print str(url) | |
print str(body) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment