Created
January 31, 2014 11:41
-
-
Save icsaas/8730556 to your computer and use it in GitHub Desktop.
tornado example
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
from tornado import ioloop | |
from tornado.httpclient import AsyncHttpClient | |
urls=['http://www.google.com/','http://baidu.com'] | |
def print_head(response): | |
print '%s: %s bytes: %r' %(response.request.url,len(response.body),response.body[:50]) | |
http_client=AsyncHTTPClient() | |
for url in urls: | |
print 'Starting %s' % url | |
http_client.fetch(url,print_head) | |
ioloop.IOLoop.instance().start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment