def until_connected(self, timeout=None):
        """Return future that resolves when the client is connected."""
        t0 = self.ioloop.time()
        yield self.until_running(timeout=timeout)
        t1 = self.ioloop.time()
        if timeout:
            timedelta = timeout - (t1 - t0)
        else:
            timedelta = None
        assert get_thread_ident() == self.ioloop_thread_id
        yield self._connected.until_set(timeout=timedelta)
Return future that resolves when the client is connected.