def wait(self, state, interval=0.1, channel=None):
        """Poll for the given state(s) at intervals; publish to channel."""
        states = set(always_iterable(state))

        while self.state not in states:
            time.sleep(interval)
            self.publish(channel)
Poll for the given state(s) at intervals; publish to channel.
cherrypy/process/wspbus.py