σ
O'^c           @@  sι  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d d l m	 Z	 d d l
 m Z m Z d d l m Z m Z m Z e j d k Z e e d	  Z e j d  d
 k Z e pα e pα e pα e e d  sσ e d   n  e j d k re j n e j Z g  Z d a d a e   a d e f d     YZ  d   Z! e  j" e# e  j$  e!  d   Z% e  j" e# e& j'  e%  e  j" e# e( j)  e%  y d  d l* m+ Z+ Wn e k
 rΙn# Xd   Z, d   Z- e  j" e+ e,  d d  Z. e j d k r(d  d l/ Z/ d   Z0 d   Z1 n d   Z0 d   Z1 d   Z2 e2 d  e e2 e2  d   Z3 d   Z4 d   Z5 d   Z6 d   Z7 d   Z8 d  d   Z9 d!   Z: d"   Z; e  j" e j e:  e j d k rεd#   Z< d$   Z= n  d S(%   i    (   t   absolute_importN(   t   Pickleri   (   t   current_process(   t	   _billiardt   win32(   t   register_after_forkt   debugt	   sub_debugR   t   pypy_version_infoi   t   recvfds%   pickling of connections not supportedt   ForkingPicklerc           B@  s&   e  Z e j j   Z e d     Z RS(   c         @  s      f d   } | |  j  | <d  S(   Nc         @  s#     |  } |  j  d | |  d  S(   Nt   obj(   t   save_reduce(   t   selfR   t   rv(   t   reduce(    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt
   dispatcher2   s    (   t   dispatch(   t   clst   typeR   R   (    (   R   s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   register0   s    (   t   __name__t
   __module__R   R   t   copyt   classmethodR   (    (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyR
   -   s   c         C@  sH   |  j  d  k r+ t |  j  j |  j j f f St |  j  |  j j f f Sd  S(   N(   t   __self__t   Nonet   getattrt	   __class__t   __func__R   (   t   m(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   _reduce_method8   s    c         C@  s   t  |  j |  j f f S(   N(   R   t   __objclass__R   (   R   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   _reduce_method_descriptor@   s    (   t   partialc         C@  s"   t  |  j |  j |  j p i  f f S(   N(   t   _rebuild_partialt   funct   argst   keywords(   t   p(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   _reduce_partialK   s    c         C@  s   t  |  | |  S(   N(   R"   (   R$   R%   R&   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyR#   N   s    c         C@  s   t  | |  j |   d  S(   N(   R
   t   dump(   R   t   filet   protocol(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyR)   S   s    c         C@  sZ   d d l  m } t j t j t |  } z  | | |  } |  j |  Wd  t |  Xd  S(   Ni   (   t	   duplicate(   t   forkingR,   R   t   OpenProcesst   PROCESS_ALL_ACCESSt   Falset   sendt   close(   t   connt   handlet   destination_pidR,   t   process_handlet
   new_handle(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   send_handle^   s    c         C@  s
   |  j    S(   N(   t   recv(   R3   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   recv_handlei   s    c         C@  s   t  j |  j   |  d  S(   N(   R   t   sendfdt   fileno(   R3   R4   R5   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyR8   m   s    c         C@  s   t  j |  j    S(   N(   R   R	   R<   (   R3   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyR:   p   s    c         C@  s;   x t  D] } t |  q Wt  j   t j   a d  a d  S(   N(   t   _cacheR2   t   cleart	   threadingt   Lockt   _lockR   t	   _listener(   R   t   h(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   _resetx   s
    
c          C@  s   t  d  k r t j   zg t  d  k r| d d l m }  t d  |  d t   j  a  t	 j
 d t  } t | _ | j   n  Wd  t j   Xn  t  S(   Ni   (   t   Listeners0   starting listener and thread for sending handlest   authkeyt   target(   RB   R   RA   t   acquiret
   connectionRE   R   R   RF   R?   t   Threadt   _servet   Truet   daemont   startt   release(   RE   t   t(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   _get_listener   s    

	c          C@  s   d d l  m }  m } x} yS t j   } | j   \ } } t j |  t | | |  t	 |  | j	   Wq |    s | d d t
 q q Xq Wd  S(   Ni   (   t
   is_exitingt   sub_warnings+   thread for sharing handles raised exceptiont   exc_info(   t   utilRR   RS   RB   t   acceptR9   R=   t   removeR8   R2   RL   (   RR   RS   R3   t   handle_wantedR5   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyRK      s    
		c         C@  sq   d d l  m } m } | j   r8 d  | j |   t f S| |   } t j |  t	 d |   t
   j | t f S(   Ni   (   t   PopenR,   s   reducing handle %d(   R-   RY   R,   t   thread_is_spawningR   t   duplicate_for_childRL   R=   t   addR   RQ   t   addressR0   (   R4   RY   R,   t
   dup_handle(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   reduce_handle¬   s    c         C@  s   d d l  m } |  \ } } } | r) | St d |  | | d t   j } | j | t j   f  t |  } | j	   | S(   Ni   (   t   Clients   rebuilding handle %dRF   (
   RI   R`   R   R   RF   R1   t   ost   getpidR:   R2   (   t   pickled_dataR`   R]   R4   t	   inheritedR3   R7   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   rebuild_handleΆ   s    
c         C@  s+   t  |  j    } t | |  j |  j f f S(   N(   R_   R<   t   rebuild_connectiont   readablet   writable(   R3   t   rh(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   reduce_connectionΗ   s    c         C@  s%   t  |   } t j | d | d | S(   NRg   Rh   (   Re   R   t
   Connection(   t   reduced_handleRg   Rh   R4   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyRf   Μ   s    c         C@  sC   t  j |  | | |  } | j t  j  k	 r? t  j  d |  } n  | S(   Nt   _sock(   t   sockett   fromfdR   (   t   fdt   familyt   type_t   protot   s(    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyRo   Φ   s    c         C@  s1   t  |  j    } t | |  j |  j |  j f f S(   N(   R_   R<   t   rebuild_socketRq   R   Rs   (   Rt   Rl   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   reduce_socketέ   s    c         C@  s/   t  |   } t | | | |  } t |  | S(   N(   Re   Ro   R2   (   Rl   Rq   Rr   Rs   Rp   Rm   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyRu   β   s    
c         C@  s+   t  |  j    } t | |  j |  j f f S(   N(   R_   R<   t   rebuild_pipe_connectionRg   Rh   (   R3   Ri   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   reduce_pipe_connectionπ   s    c         C@  s%   t  |   } t j | d | d | S(   NRg   Rh   (   Re   R   t   PipeConnection(   Rl   Rg   Rh   R4   (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyRw   τ   s    (>   t
   __future__R    Ra   t   sysRn   R?   t   pickleR   t    R   t   _extR   R   RU   R   R   R   t   platformt   is_win32t   hasattrt   is_pypyt   version_infot   is_py3kt   ImportErrort   CloseHandleR2   t   __all__R   RB   RA   t   setR=   R
   R   R   R   t   saveR!   t   listt   appendt   intt   __add__t	   functoolsR"   R(   R#   R)   t   _subprocessR8   R:   RD   RQ   RK   R_   Re   Rj   Rf   Ro   Rv   Ru   Rx   Rw   (    (    (    s8   /tmp/pip-unpacked-wheel-40MfcW/billiard/py2/reduction.pyt   <module>   sl   !!									
			
			
			