ó
ÐH/\c           @   sR   d  Z  d d l Z d d l m Z d g Z d j d ƒ d e f d „  ƒ  YZ d S(   s(   
Native thread-based hostname resolver.
iÿÿÿÿN(   t   get_hubt   Resolveru   foot   idnac           B   sY   e  Z d  Z d	 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(
   s¹  
    Implementation of the resolver API using native threads and native resolution
    functions.

    Using the native resolution mechanisms ensures the highest
    compatibility with what a non-gevent program would return
    including good support for platform specific configuration
    mechanisms. The use of native (non-greenlet) threads ensures that
    a caller doesn't block other greenlets.

    This implementation also has the benefit of being very simple in comparison to
    :class:`gevent.resolver_ares.Resolver`.

    .. tip::

        Most users find this resolver to be quite reliable in a
        properly monkey-patched environment. However, there have been
        some reports of long delays, slow performance or even hangs,
        particularly in long-lived programs that make many, many DNS
        requests. If you suspect that may be happening to you, try the
        dnspython or ares resolver (and submit a bug report).
    c         C   sX   | d  k r t ƒ  } n  | j |  _ t j | j k rT | j t j t j f 7_ n  d  S(   N(   t   NoneR    t
   threadpoolt   poolt   _sockett   gaierrort	   NOT_ERRORt   herror(   t   selft   hub(    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyt   __init__(   s
    c         C   s   d t  |  ƒ |  j f S(   Ns1   <gevent.resolver_thread.Resolver at 0x%x pool=%r>(   t   idR   (   R
   (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyt   __repr__1   s    c         C   s   d  S(   N(    (   R
   (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyt   close4   s    c         G   s   |  j  j t j | ƒ S(   N(   R   t   applyR   t   gethostbyname(   R
   t   args(    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyR   :   s    c         G   s   |  j  j t j | ƒ S(   N(   R   R   R   t   gethostbyname_ex(   R
   R   (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyR   =   s    c         O   s   |  j  j t j | | ƒ S(   N(   R   R   R   t   getaddrinfo(   R
   R   t   kwargs(    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyR   @   s    c         O   s   |  j  j t j | | ƒ S(   N(   R   R   R   t   gethostbyaddr(   R
   R   R   (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyR   C   s    c         O   s   |  j  j t j | | ƒ S(   N(   R   R   R   t   getnameinfo(   R
   R   R   (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyR   F   s    N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyR      s   							(   R   R   t
   gevent.hubR    t   __all__t   encodet   objectR   (    (    (    s5   lib/python2.7/site-packages/gevent/resolver/thread.pyt   <module>   s
   	