code: def wait_with_ioloop(self, ioloop, timeout=None):
          
          f = Future()
  
          def cb():
              return gen.chain_future(self.until_set(), f)
          ioloop.add_callback(cb)
          try:
              f.result(timeout)
              return True
          except TimeoutError:
              return self._flag
docs: Do blocking wait until condition is event is set.
  
          Parameters
          ----------
          ioloop : tornadio.ioloop.IOLoop instance
              MUST be the same ioloop that set() / clear() is called from
          timeout : float, int or None
              If not None, only wait up to `timeout` seconds for event to be set.
  
          Return Value
          ------------
          flag : True if event was set within timeout, otherwise False.
  
          Notes
          -----
          This will deadlock if called in the ioloop!