σ
ίόΪ\c           @` s  d  d l  m Z m Z m Z d  d l Z d  d l Z e j d  d k rWd  d l m Z m Z d  d l	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z d  d	 l m Z m Z m Z m Z d  d
 l m Z e Z e Z e Z e Z e  Z! e  Z" d e# f d     YZ$ d  d l% Z% d   Z& d   Z' d   Z( d   Z) d   Z* e j+ Z, d   Z- n  e j d  d k rd  d l. m- Z- d  d	 l/ m Z m Z m Z m Z d  d l0 m Z m Z d  d l1 m Z d  d l2 m Z d  d l1 m) Z) d  d l3 m* Z* d  d l m4 Z d  d l5 m Z d  d
 l6 m Z e Z e Z e7 Z d  d l% m8 Z& d  d l% m9 Z' e! Z! e" Z" e$ Z$ d   Z( e j: j;   Z, e, j< e j=  n  d  d l> Z> e> j?   j@   d k ZA e j> jB d  ZC y d  d lD mE ZE Wn eF eG f k
 rϊeH ZE n Xy d  d lI mJ ZJ Wn! eF k
 r2d  d lJ mJ ZJ n Xy d  d  lK mL ZL WnC eF k
 rd  d lM ZM d  d! lK mN ZN d" eO f d#     YZL n Xd S($   i    (   t   print_functiont   divisiont   absolute_importNi   (   t   Queuet   Empty(   t   BytesIO(   t	   get_ident(   t
   getargspec(   t   escape(   t   Iteratort   Mappingt   Sett   MutableMapping(   t   gcdt   StopAsyncIterationc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyR      s   c         C` s2   t  j d t |    } | j   } | j   | S(   Nt   fileobj(   t   gzipt   GzipFileR   t   readt   close(   t   bt   ft   result(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   gzip_decompress   s    
c         C` sU   t    } t j d | d d  } | j |   | j   | j d  | j   } | S(   NR   t   modet   wi    (   R   R   R   t   writeR   t   seekR   (   R   t   bioR   R   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   gzip_compress#   s    	
c         C` s+   t  |  d  o* t  |  d  o* |  j d k S(   Nt   queueR   R   (   t   hasattrR   (   t   o(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   isqueue,   s    c           C` s   d  S(   N(    (    (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   invalidate_caches1   s    c         C` s,   d d  l  } | j j |   \ } } | d S(   Ni    s   .pyc(   t   ost   patht   splitext(   R&   R%   t   namet   ext(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   cache_from_source4   s    c         C` s   t  S(   N(   t   False(   t   func(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   iscoroutinefunction<   s    i   (   R-   (   t   reload(   R$   (   R*   (   t   getfullargspec(   t
   decompress(   t   compressc         C` s   t  |  t  S(   N(   t
   isinstanceR   (   R"   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyR#   V   s    t   pypyt   win(   t   JSONDecodeError(   t   singledispatch(   t   finalize(   t   refR7   c           B` sΙ   e  Z d  Z d Z i  Z e Z e j   Z	 e Z
 e Z d d d     YZ d   Z d d  Z d   Z d   Z e d    Z e d    Z e j d	    Z d
   Z e d    Z e d    Z RS(   s6  Class for finalization of weakrefable objects

        finalize(obj, func, *args, **kwargs) returns a callable finalizer
        object which will be called when obj is garbage collected. The
        first time the finalizer is called it evaluates func(*arg, **kwargs)
        and returns the result. After this the finalizer is dead, and
        calling it just returns None.

        When the program exits any remaining finalizers for which the
        atexit attribute is true will be run in reverse order of creation.
        By default atexit is true.
        t   _Infoc           B` s   e  Z d Z RS(   t   weakrefR,   t   argst   kwargst   atexitt   index(   R:   R,   R;   R<   R=   R>   (   R   R   t	   __slots__(    (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyR9      s   c         O` s₯   |  j  s1 d d  l } | j |  j  t t _  n  |  j   } t | |   | _ | | _	 | | _
 | pj d  | _ t | _ t |  j  | _ | |  j |  <t t _ d  S(   Ni    (   t   _registered_with_atexitR=   t   registert	   _exitfunct   TrueR7   R9   R8   R:   R,   R;   t   NoneR<   t   nextt   _index_iterR>   t	   _registryt   _dirty(   t   selft   objR,   R;   R<   R=   t   info(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   __init__   s    				c         C` sE   |  j  j |  d  } | rA |  j rA | j | j | j p= i    Sd S(   s^   If alive then mark as dead and return func(*args, **kwargs);
            otherwise return NoneN(   RG   t   popRD   t	   _shutdownR,   R;   R<   (   RI   t   _RK   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   __call__’   s    c         C` sh   |  j  j |   } | o! | j   } | d k	 rd |  j  j |  d  rd | | j | j | j p` i  f Sd S(   sb   If alive then mark as dead and return (obj, func, args, kwargs);
            otherwise return NoneN(   RG   t   getR:   RD   RM   R,   R;   R<   (   RI   RK   RJ   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   detach©   s    !c         C` sS   |  j  j |   } | o! | j   } | d k	 rO | | j | j | j pK i  f Sd S(   sQ   If alive then return (obj, func, args, kwargs);
            otherwise return NoneN(   RG   RQ   R:   RD   R,   R;   R<   (   RI   RK   RJ   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   peek±   s    c         C` s   |  |  j  k S(   s   Whether finalizer is alive(   RG   (   RI   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   aliveΉ   s    c         C` s%   |  j  j |   } t |  o$ | j S(   s*   Whether finalizer should be called at exit(   RG   RQ   t   boolR=   (   RI   RK   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyR=   Ύ   s    c         C` s.   |  j  j |   } | r* t |  | _ n  d  S(   N(   RG   RQ   RU   R=   (   RI   t   valueRK   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyR=   Δ   s    c         C` s   |  j  j |   } | o! | j   } | d  k rM d t |   j t |   f Sd t |   j t |   t |  j t |  f Sd  S(   Ns   <%s object at %#x; dead>s!   <%s object at %#x; for %r at %#x>(   RG   RQ   R:   RD   t   typeR   t   id(   RI   RK   RJ   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   __repr__Κ   s    	c         C` sg   g  |  j  j   D]! \ } } | j r | | f ^ q } | j d d    g  | D] \ } } | ^ qQ S(   Nt   keyc         S` s   |  d j  S(   Ni   (   R>   (   t   item(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   <lambda>Ϋ   t    (   RG   t   itemsR=   t   sort(   t   clsR   t   it   L(    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   _select_for_exitΧ   s    7c         C` s  t  } zΨ |  j rέ d d  l } | j   r= t } | j   n  d  } x t rΩ | d  k sa t j ry |  j	   } t  t _ n  | s Pn  | j
   } y |   Wn$ t k
 rΐ t j t j     n X| |  j k sF t  qF Wn  Wd  t t _ | rύ | j   n  Xd  S(   Ni    (   R+   RG   t   gct	   isenabledRC   t   disableRD   R7   RH   Rc   RM   t	   Exceptiont   syst
   excepthookt   exc_infot   AssertionErrorRN   t   enable(   R`   t   reenable_gcRd   t   pendingR   (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyRB   ή   s.    		 	(    (    N(   R   R   t   __doc__R?   RG   R+   RN   t	   itertoolst   countRF   RH   R@   R9   RL   RD   RP   RR   RS   t   propertyRT   R=   t   setterRY   t   classmethodRc   RB   (    (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyR7   t   s$   				(P   t
   __future__R    R   R   t   loggingRh   t   version_infoR   R   t   ioR   t   threadR   t   get_thread_identityt   inspectR   t   cgiR   t   html_escapet   collectionsR	   R
   R   R   t	   fractionsR   R.   t   unicodeRC   t   PY2R+   t   PY3t   OSErrort   ConnectionRefusedErrort   FileExistsErrorRg   R   R   R   R   R#   R$   R*   t   _levelNamest   logging_namesR-   t   asynciot   collections.abcR    t	   importlibt	   threadingt   importlib.utilR/   t   htmlt   matht   strR0   R1   t   _levelToNamet   copyt   updatet   _nameToLevelt   platformt   python_implementationt   lowert   PYPYt
   startswitht   WINDOWSt   json.decoderR5   t   ImportErrort   AttributeErrort
   ValueErrort	   functoolsR6   R:   R7   Rp   R8   t   object(    (    (    s8   lib/python2.7/site-packages/distributed/compatibility.pyt   <module>   s   "							"	
