'Poll for the given state(s) at intervals; publish to channel.'

def wait(self, state, interval=0.1, channel=None):

    if isinstance(state, (tuple, list)):
        states = state
    else:
        states = [state]
    def _wait():
        while (self.state not in states):
            time.sleep(interval)
            self.publish(channel)
    try:
        sys.modules['psyco'].cannotcompile(_wait)
    except (KeyError, AttributeError):
        pass
    _wait()
