Created
September 27, 2012 21:53
Revisions
-
kzahel revised this gist
Sep 27, 2012 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,13 +2,15 @@ def asyncsleep(t, callback=None): ioloop.add_timeout( time.time() + t, callback ) class NestedYieldAsync(tornado.web.RequestHandler): @tornado.web.asynchronous @tornado.gen.engine def get(self): yield gen.Task( self.lots_of_waits ) yield gen.Task( self.lots_of_waits ) self.finish() @tornado.gen.engine def lots_of_waits(self, callback=None): for i in range(3): print 'sleep',i -
kzahel revised this gist
Sep 27, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ class NestedYieldAsync(tornado.web.RequestHandler): def get(self): yield gen.Task( self.lots_of_waits ) yield gen.Task( self.lots_of_waits ) self.finish() @gen.engine def lots_of_waits(self, callback=None): for i in range(3): -
kzahel created this gist
Sep 27, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ def asyncsleep(t, callback=None): ioloop.add_timeout( time.time() + t, callback ) class NestedYieldAsync(tornado.web.RequestHandler): @tornado.web.asynchronous @gen.engine def get(self): yield gen.Task( self.lots_of_waits ) yield gen.Task( self.lots_of_waits ) @gen.engine def lots_of_waits(self, callback=None): for i in range(3): print 'sleep',i yield gen.Task( asyncsleep, 1 ) callback()