code: def ensure_connectable(self, nailgun):
      
      attempt_count = 1
      while 1:
        try:
          with closing(nailgun.try_connect()) as sock:
            logger.debug('Verified new ng server is connectable at {}'.format(sock.getpeername()))
            return
        except nailgun.NailgunConnectionError:
          if attempt_count >= self._connect_attempts:
            logger.debug('Failed to connect to ng after {} attempts'.format(self._connect_attempts))
            raise     # Re-raise the NailgunConnectionError which provides more context to the user.
  
        attempt_count += 1
        time.sleep(self.WAIT_INTERVAL_SEC)
docs: Ensures that a nailgun client is connectable or raises NailgunError.