config.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
def _gen_addresses_where_possible(hostname):
    """Yield IPv4 and IPv6 addresses for `hostname`.

    A variant of `_gen_addresses` that ignores some resolution failures. The
    addresses returned are only those that are resolvable at the time this
    function is called. Specifically the following errors are ignored:

      +----------------+-----------------------------------------------+
      | EAI_ADDRFAMILY | The specified network host does not have any  |
      |                | network addresses in the requested address    |
      |                | family.                                       |
      +----------------+-----------------------------------------------+
      | EAI_AGAIN      | The name server returned a temporary failure  |
      |                | indication. Try again later.                  |
      +----------------+-----------------------------------------------+
      | EAI_FAIL       | The name server returned a permanent failure  |
      |                | indication.                                   |
      +----------------+-----------------------------------------------+
      | EAI_NODATA     | The specified network host exists, but does   |
      |                | not have any network addresses defined.       |
      +----------------+-----------------------------------------------+
      | EAI_NONAME     | The node or service is not known; or both node|
      |                | and service are NULL; or AI_NUMERICSERV was   |
      |                | specified and service was not a numeric       |
      |                | port-number string.                           |
      +----------------+-----------------------------------------------+

    Descriptions from getaddrinfo(3).
    """
    try:
        yield from _gen_addresses(hostname)
    except socket.gaierror as error:
        if error.errno in _gen_addresses_where_possible_suppress:
            # Log this but otherwise suppress/ignore for now.
            logger.warning("Could not resolve %s: %s", hostname, error)
        else:
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号