<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def until_state(self, state, timeout=None):
 """Return a tornado Future that will resolve when the requested state is set"""

        if state not in self._valid_states:
            raise ValueError('State must be one of {0}, not {1}'
                             .format(self._valid_states, state))
        if state != self._state:
            if timeout:
                return with_timeout(self._ioloop.time() + timeout,
                                    self._waiting_futures[state],
                                    self._ioloop)
            else:
                return self._waiting_futures[state]
        else:
            f = tornado_Future()
            f.set_result(True)
            return f