docs: def resolve(hostname, family=AF_UNSPEC):
      """
      Resolve hostname to one or more IP addresses through the operating system.
  
      Resolution is carried out for the given address family. If no
      address family is specified, only IPv4 and IPv6 addresses are returned. If
      multiple IP addresses are found, all are returned.
  
      :param family: AF_INET or AF_INET6 or AF_UNSPEC (default)
      :return: tuple of unique IP addresses
      """
      af_ok = (AF_INET, AF_INET6)
      if family != AF_UNSPEC and family not in af_ok:
          raise ValueError("Invalid family '%s'" % family)
      ips = ()
      try:
          addrinfo = socket.getaddrinfo(hostname, None, family)
      except socket.gaierror as exc:
          # EAI_NODATA and EAI_NONAME are expected if this name is not (yet)
          # present in DNS
          if exc.errno not in (socket.EAI_NODATA, socket.EAI_NONAME):
              LOG.debug("socket.getaddrinfo() raised an exception", exc_info=exc)
      else:
          if family == AF_UNSPEC:
              ips = tuple({item[4][0] for item in addrinfo if item[0] in af_ok})
          else:
              ips = tuple({item[4][0] for item in addrinfo})
      return ips