<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wait_with_ioloop(self, ioloop, timeout=None):
 """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! """

        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