Skip to content

Instantly share code, notes, and snippets.

@dano

dano/torn.py Secret

Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dano/19668618c513a33ccce6 to your computer and use it in GitHub Desktop.
Save dano/19668618c513a33ccce6 to your computer and use it in GitHub Desktop.
Tornado calling a method that uses yield internally.
#!/usr/bin/python
import tornado.web
import tornado.ioloop
def testgen(n):
for i in xrange(n):
yield i
def test():
return ' '.join([str(i) for i in testgen(10)])
class TestHandler(tornado.web.RequestHandler):
def get(self):
self.write(test())
if __name__ == "__main__":
app = tornado.web.Application([
(r'/test', TestHandler),
])
app.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment