Skip to content

Instantly share code, notes, and snippets.

@lwzm
Created June 21, 2014 11:12
Show Gist options
  • Select an option

  • Save lwzm/d2ddfaf2374ac7ab459d to your computer and use it in GitHub Desktop.

Select an option

Save lwzm/d2ddfaf2374ac7ab459d to your computer and use it in GitHub Desktop.
class Sleep(RequestHandler):
@tornado.web.asynchronous
def get(self):
self.set_header("Content-Type", "text/plain")
self.loop(100)
def loop(self, n):
if not n:
return self.finish()
self.write("{}\n".format(n))
self.flush()
io_loop.add_timeout(delay, lambda: self.loop(n - 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment