Skip to content

Instantly share code, notes, and snippets.

@sharvell
Forked from emre/gevent_tornado.py
Created April 2, 2013 11:17
Show Gist options
  • Select an option

  • Save sharvell/5291526 to your computer and use it in GitHub Desktop.

Select an option

Save sharvell/5291526 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import tornado.httpclient
import tornado.ioloop
import gevent
def on_complete(data):
print data.body[0:10]
def print_head(url):
print ('Starting %s' % url)
http = tornado.httpclient.AsyncHTTPClient()
http.fetch("http://friendfeed.com", on_complete)
jobs = [gevent.spawn(print_head, url) for url in range(0, 50)]
gevent.joinall(jobs)
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment