<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_for(self, timeout=3000):
 """Hault execution until self resolves."""

        results = [None]
        results_called = [False]

        def results_callback(val):
            results[0] = val
            results_called[0] = True

        self.then(results_callback)

        start = time.time()
        while not results_called[0]:
            if time.time() - start > timeout / 1000.:
                raise Exception('Timeout of %d ms reached' % timeout)
            ip.kernel.do_one_iteration()
        return results[0]