Skip to content

Instantly share code, notes, and snippets.

@swshan
Created September 17, 2015 02:30
Show Gist options
  • Save swshan/931832a37906521a4d47 to your computer and use it in GitHub Desktop.
Save swshan/931832a37906521a4d47 to your computer and use it in GitHub Desktop.
Python exercises
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
print str(body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment