@contextlib.contextmanager
def current_ioloop(io_loop):
 orig_loop = tornado.ioloop.IOLoop.current()
 io_loop.make_current()
 try:
  (yield)
 finally:
  orig_loop.make_current()

@ contextlib . contextmanager def current_ioloop ( io_loop ) : orig_loop = tornado . ioloop . IOLoop . current ( ) io_loop . make_current ( ) try : ( yield ) finally : orig_loop . make_current ( )
a context manager that will set the current ioloop to io_loop for the context .