code: def wait_for_connection(self, timeout=None):
          
          if timeout is not None:
              wait_time = timeout / 10.0
          else:
              wait_time = None
          with self.__connect_wait_condition:
              while self.running and not self.is_connected() and not self.connection_error:
                  self.__connect_wait_condition.wait(wait_time)
          if not self.running or not self.is_connected():
              raise exception.ConnectFailedException()
docs: Wait until we've established a connection with the server.
  
          :param float timeout: how long to wait, in seconds