-
-
Save dano/19668618c513a33ccce6 to your computer and use it in GitHub Desktop.
Tornado calling a method that uses yield internally.
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
#!/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