util.py 266 B

123456789101112
  1. # encoding=utf-8
  2. import datetime
  3. import tornado.gen
  4. import tornado.ioloop
  5. @tornado.gen.coroutine
  6. def sleep(seconds):
  7. deadline = datetime.timedelta(seconds=seconds)
  8. yield tornado.gen.Task(
  9. tornado.ioloop.IOLoop.current().add_timeout, deadline
  10. )