_socket.py 文件源码

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

项目:trio 作者: python-trio 项目源码 文件源码
def set_custom_hostname_resolver(hostname_resolver):
    """Set a custom hostname resolver.

    By default, trio's :func:`getaddrinfo` and :func:`getnameinfo` functions
    use the standard system resolver functions. This function allows you to
    customize that behavior. The main intended use case is for testing, but it
    might also be useful for using third-party resolvers like `c-ares
    <https://c-ares.haxx.se/>`__ (though be warned that these rarely make
    perfect drop-in replacements for the system resolver). See
    :class:`trio.abc.HostnameResolver` for more details.

    Setting a custom hostname resolver affects all future calls to
    :func:`getaddrinfo` and :func:`getnameinfo` within the enclosing call to
    :func:`trio.run`. All other hostname resolution in trio is implemented in
    terms of these functions.

    Generally you should call this function just once, right at the beginning
    of your program.

    Args:
      hostname_resolver (trio.abc.HostnameResolver or None): The new custom
          hostname resolver, or None to restore the default behavior.

    Returns: 
      The previous hostname resolver (which may be None).

    """
    old = _overrides.hostname_resolver
    _overrides.hostname_resolver = hostname_resolver
    return old
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号