Skip to content

Instantly share code, notes, and snippets.

@icsaas
Created January 31, 2014 11:41
Show Gist options
  • Save icsaas/8730556 to your computer and use it in GitHub Desktop.
Save icsaas/8730556 to your computer and use it in GitHub Desktop.
tornado example
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