
O'^c           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d d l m Z m	 Z	 m
 Z
 m Z m Z m Z d d l m Z m Z m Z d d l m Z d d l m Z m Z d d	 l m Z d d
 l m Z m Z m Z d d d d g Z d   Z e j e j e  g  d d d f D] Z e  e! i  e     ^ qZ" e" d  e# k	 rd   Z$ xR e" D]J Z% e j e% e$  y d  d l& Z& Wn e' k
 rn Xe& j( e% e$  qbWn  d e) f d     YZ* f  i  d  Z+ d   Z, d e- f d     YZ. d   Z/ d   Z0 d e) f d     YZ1 d e) f d     YZ2 i e j3 e j4 f d 6e j5 e j6 f d  6Z7 d e) f d!     YZ8 d" e9 f d#     YZ: d e) f d$     YZ; d%   Z< i  d&  Z= e> e> e> e? d'  Z@ d( e) f d)     YZA d* e) f d+     YZB e? d,  ZC d- e; f d.     YZD d/ e; f d0     YZE d1 eE f d2     YZF d3 e; f d4     YZG d5 e; f d6     YZH d7 e; f d8     YZI e= d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO f  ZJ dP eJ f dQ     YZK e= dR d; d< d> d@ dD dS dT dU dV d d dK dW dX dY d f  ZL e= dZ d@ d> dD d? dE f  ZM e= d[ d\ d] d^ d_ d` da db dc dd de df f  ZN i dg d] 6dg dc 6dg de 6dh d_ 6dh d` 6eN _O d e8 f di     YZP eP j dj e  eP j dk e  eP j dl e jQ eG  eP j dm e jR eE  eP j dn e jS eE  eP j do e jT eE  eP j dp e jU eE  eP j dq e jV eF  eP j dr e eN  eP j ds e# eK  eP j dt eW eL  eP j d* eB eI  eP j du eC eM  eP j d( eA eH  eP j dh dv eD dw eX eP j dg dw eX d S(x   i    (   t   absolute_importN(   t
   format_exci   (   t   Processt   current_processt   active_childrent   Poolt   utilt
   connection(   t   Queuet   itemst	   monotonic(   t   AuthenticationString(   t   exitt   Popen(   t   ForkingPickler(   t   Finalizet   errort   infot   BaseManagert   SyncManagert	   BaseProxyt   Tokenc         C@  s   t  j  |  j |  j   f f S(   N(   t   arrayt   typecodet   tostring(   t   a(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   reduce_array$   s    R	   t   keyst   valuesc         C@  s   t  t  |   f f S(   N(   t   list(   t   obj(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   rebuild_as_list,   s    c           B@  s8   e  Z d  Z d Z d   Z d   Z d   Z d   Z RS(	   s4   
    Type to uniquely indentify a shared object
    t   typeidt   addresst   idc         C@  s!   | | | |  _  |  _ |  _ d  S(   N(   R    R!   R"   (   t   selfR    R!   R"   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __init__B   s    c         C@  s   |  j  |  j |  j f S(   N(   R    R!   R"   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __getstate__E   s    c         C@  s   | \ |  _  |  _ |  _ d  S(   N(   R    R!   R"   (   R#   t   state(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __setstate__H   s    c         C@  s   d |  j  |  j |  j f S(   Ns#   Token(typeid=%r, address=%r, id=%r)(   R    R!   R"   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __repr__K   s    (   R    R!   R"   (   t   __name__t
   __module__t   __doc__t	   __slots__R$   R%   R'   R(   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   <   s   			c         C@  sN   |  j  | | | | f  |  j   \ } } | d k r; | St | |   d S(   sL   
    Send a message to manager using connection `c` and return response
    s   #RETURNN(   t   sendt   recvt   convert_to_error(   t   cR"   t
   methodnamet   argst   kwdst   kindt   result(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   dispatchT   s
    c         C@  s~   |  d k r | S|  d k r> t  |  t k s4 t  t |  S|  d k rp t  |  t k sb t  t d |  St d  Sd  S(   Ns   #ERRORs
   #TRACEBACKs   #UNSERIALIZABLEs   Unserializable message: %s
s   Unrecognized message type(   t   typet   strt   AssertionErrort   RemoteErrort
   ValueError(   R4   R5   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR/   _   s    
R:   c           B@  s   e  Z d    Z RS(   c         C@  s)   d d d d t  |  j d  d d S(   Ns   
t   -iK   i    (   R8   R2   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __str__n   s    (   R)   R*   R=   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR:   l   s   c         C@  sL   g  } x? t  |   D]1 } t |  |  } t |  r | j |  q q W| S(   s4   
    Return a list of names of methods of `obj`
    (   t   dirt   getattrt   callablet   append(   R   t   tempt   namet   func(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   all_methodsv   s    c         C@  s-   g  t  |   D] } | d d k r | ^ q S(   sP   
    Return a list of names of methods of `obj` which do not start with '_'
    i    t   _(   RE   (   R   RC   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   public_methods   s    t   Serverc        	   B@  s   e  Z d  Z d d d d d d d d d	 g	 Z d
   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 i e	 d 6e
 d 6e d 6Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sM   
    Server class which runs in a process controlled by a manager object
    t   shutdownt   createt   accept_connectiont   get_methodst
   debug_infot   number_of_objectst   dummyt   increft   decrefc         C@  s   t  | t  s t  | |  _ t |  |  _ t | \ } } | d | d d  |  _ |  j j |  _ i d  d f d 6|  _
 i  |  _ t j   |  _ d |  _ d  S(   NR!   t   backlogi   t   0i    (    (   t
   isinstancet   bytesR9   t   registryR   t   authkeyt   listener_clientt   listenerR!   t   Nonet	   id_to_objt   id_to_refcountt	   threadingt   RLockt   mutext   stop(   R#   RV   R!   RW   t
   serializert   Listenert   Client(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$      s    		c         C@  s   |  t    _ z yl xe y |  j j   } Wn t t f k
 rD q n Xt j d |  j d | f  } t	 | _
 | j   q WWn t t f k
 r n XWd d |  _ |  j j   Xd S(   s(   
        Run the server forever
        t   targetR2   Ni  (   R   t   _manager_serverRY   t   acceptt   OSErrort   IOErrorR]   t   Threadt   handle_requestt   Truet   daemont   startt   KeyboardInterruptt
   SystemExitR`   t   close(   R#   R0   t   t(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   serve_forever   s    		c         C@  sv  d } } } yv t j | |  j  t j | |  j  | j   } | \ } } } } | |  j k st t d |   t |  |  } Wn  t	 k
 r d t
   f }	 nF Xy | | | |  } Wn  t	 k
 r d t
   f }	 n Xd | f }	 y | j |	  Wnh t	 k
 rg}
 y | j d t
   f  Wn t	 k
 r<n Xt d |	  t d |  t d |
  n X| j   d S(   s)   
        Handle a new connection
        s   %r unrecognizeds
   #TRACEBACKs   #RETURNs   Failure to send message: %rs    ... request was %rs    ... exception was %rN(   RZ   R   t   deliver_challengeRW   t   answer_challengeR.   t   publicR9   R?   t	   ExceptionR   R-   R   Rp   (   R#   R0   t   funcnameR5   t   requestt   ignoreR2   R3   RD   t   msgt   exc(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRj      s4    c         C@  s  t  j d t j   j  | j } | j } |  j } x|  j syd } } |   } | \ } } }	 }
 | | \ } } } | | k r t
 d | t |  | f   n  t | |  } y | |	 |
   } Wn t k
 r } d | f } np X| o| j | d  } | rP|  j | | |  \ } } t | |  j |  } d | | f f } n d | f } Wn t
 k
 r| d k rd t   f } q?y8 |  j | } | |  | | | |	 |
  } d | f } Wq?t k
 rd t   f } q?XnV t k
 rt  j d t j   j  t j d  n  t k
 r>d t   f } n Xy< y | |  Wn' t k
 ry| d	 t |  f  n XWq7 t k
 r} t d
 t j   j  t d |  t d |  | j   t j d  q7 Xq7 Wd S(   sQ   
        Handle requests from the proxies in a particular process/thread
        s$   starting server thread to service %rs+   method %r of %r object is not in exposed=%rs   #ERRORs   #PROXYs   #RETURNs
   #TRACEBACKs$   got EOF -- exiting thread serving %ri    s   #UNSERIALIZABLEs   exception in thread serving %rs    ... message was %rs    ... exception was %ri   N(   R   t   debugR]   t   currentThreadRC   R.   R-   R[   R`   RZ   t   AttributeErrorR7   R?   Rv   t   getRJ   R   R!   R   t   fallback_mappingt   EOFErrort   sysR   t   reprR   Rp   (   R#   t   connR.   R-   R[   R1   R   Rx   t   identR2   R3   t   exposedt	   gettypeidt   functiont   resR{   Rz   R    t   ridentt   rexposedt   tokent   fallback_funcR5   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   serve_client   sl    				
		
c         C@  s   | S(   N(    (   R#   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   fallback_getvalue$  s    c         C@  s
   t  |  S(   N(   R8   (   R#   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   fallback_str'  s    c         C@  s
   t  |  S(   N(   R   (   R#   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   fallback_repr*  s    R=   R(   s	   #GETVALUEc         C@  s   d  S(   N(    (   R#   R0   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRO   3  s    c         C@  s   |  j   g  } t |  j j    } | j   xS | D]K } | d k r6 | j d | |  j | t |  j | d  d  f  q6 q6 Wd j |  SWd QXd S(   sO   
        Return some info --- useful to spot problems with refcounting
        RS   s     %s:       refcount=%s
    %si    iK   s   
N(	   R_   R   R[   R   t   sortRA   R\   R8   t   join(   R#   R0   R5   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRM   6  s    

	'c         C@  s   t  |  j  d S(   s*   
        Number of shared objects
        i   (   t   lenR[   (   R#   R0   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRN   E  s    c         C@  s  zy t  j d  | j d
  t j t j k rZ t  j d  t j t _ t j t _ n  t  j	 d  x( t
   D] } t  j d  | j   qq Wx( t
   D] } t  j d  | j   q Wt  j	   t d  Wn2 t d d t sd d	 l } | j   qn XWd	 t d  Xd	 S(   s'   
        Shutdown this process
        s!   manager received shutdown messages   #RETURNs   resetting stdout, stderri    s&   terminating a child process of managers   manager exiting with exitcode 0s   Error while manager shutdownt   exc_infoN(   s   #RETURNN(   R   R|   R-   RZ   R   t   stdoutt
   __stdout__t
   __stderr__t   stderrt   _run_finalizersR   t	   terminateR   R   R   Rk   t	   tracebackt	   print_excR   (   R#   R0   t   pR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRI   K  s,    
c         O@  sJ  |  j  ;|  j | \ } } } } | d k r[ t |  d k rH | sN t  | d }	 n | | |   }	 | d k r t |	  } n  | d k	 r t |  t k s t  t |  t |  } n  d t	 |	  }
 t
 j d | |
  |	 t |  | f |  j |
 <|
 |  j k r d |  j |
 <n  |  j | |
  |
 t |  f SWd QXd S(   s>   
        Create a new shared object and return its id
        i   i    s   %xs&   %r callable returned object with id %rN(   R_   RV   RZ   R   R9   RG   R7   t   dictR   R"   R   R|   t   setR[   R\   RP   t   tuple(   R#   R0   R    R2   R3   R@   R   t   method_to_typeidt	   proxytypeR   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRJ   l  s$    
c         C@  s   t  |  j | j d  S(   sL   
        Return the methods of the shared object indicated by token
        i   (   R   R[   R"   (   R#   R0   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRL     s    c         C@  s-   | t  j   _ | j d  |  j |  d S(   s=   
        Spawn a new thread to serve this connection
        s   #RETURNN(   s   #RETURNN(   R]   R}   RC   R-   RZ   R   (   R#   R0   RC   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRK     s    c         C@  s'   |  j   |  j | c d 7<Wd  QXd  S(   Ni   (   R_   R\   (   R#   R0   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRP     s    
c         C@  sz   |  j  k |  j | d k s# t  |  j | c d 8<|  j | d k rp |  j | =|  j | =t j d |  n  Wd  QXd  S(   Ni   i    s   disposing of obj with id %r(   R_   R\   R9   R[   R   R|   (   R#   R0   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRQ     s    
(   R)   R*   R+   Ru   R$   Rr   Rj   R   R   R   R   R   RO   RM   RN   RI   RJ   RL   RK   RP   RQ   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRH      s.   			"	J			
				!	#			t   Statec           B@  s#   e  Z d  g Z d Z d Z d Z RS(   t   valuei    i   i   (   R)   R*   R,   t   INITIALt   STARTEDt   SHUTDOWN(    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s   	t   picklet	   xmlrpclibc           B@  s   e  Z d  Z i  Z e Z d d d d  Z d   Z d   Z	 d   Z
 d d d  Z e d d d   Z d   Z d d	  Z d
   Z d   Z d   Z d   Z e d    Z e d    Z e d d d d e d   Z RS(   s!   
    Base class for managers
    R   c         C@  sq   | d  k r t   j } n  | |  _ t |  |  _ t   |  _ t j |  j _	 | |  _
 t | \ |  _ |  _ d  S(   N(   RZ   R   RW   t   _addressR   t   _authkeyR   t   _stateR   R   t   _serializerRX   t	   _Listenert   _Client(   R#   R!   RW   Ra   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$     s    		c         C@  s%   t  |   j |  j |  j |  j f f S(   N(   R7   t   from_addressR   R   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt
   __reduce__  s    c         C@  s:   |  j  j t j k s t  t |  j |  j |  j |  j	  S(   sX   
        Return server object with serve_forever() method and address attribute
        (
   R   R   R   R   R9   RH   t	   _registryR   R   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt
   get_server  s    c         C@  sN   t  |  j \ } } | |  j d |  j } t | d d  t j |  j _	 d S(   s>   
        Connect manager object to the server process
        RW   RO   N(
   RX   R   R   R   R6   RZ   R   R   R   R   (   R#   Rb   Rc   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   connect  s    c         C@  sa  |  j  j t j k s t  | d
 k	 rC t |  rC t d   n  t j	 d t
  \ } } t d t |   j d |  j |  j |  j |  j | | | f  |  _ d j d   |  j j D  } t |   j d | |  j _ |  j j   | j   | j   |  _ | j   t j |  j  _ t |  t |   j d |  j |  j |  j |  j  |  j f d d	 |  _ d
 S(   s@   
        Spawn a server process for this manager object
        s   initializer must be a callablet   duplexRd   R2   t   :c         s@  s   |  ] } t  |  Vq d  S(   N(   R8   (   t   .0t   i(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pys	   <genexpr>  s    R<   t   exitpriorityi    N(   R   R   R   R   R9   RZ   R@   t	   TypeErrorR   t   Pipet   FalseR   R7   t   _run_serverR   R   R   R   t   _processR   t	   _identityR)   RC   Rm   Rp   R.   R   R   t   _finalize_managerR   RI   (   R#   t   initializert   initargst   readert   writerR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRm     s(    

c   	      C@  si   | d k	 r | |   n  |  j | | | |  } | j | j  | j   t d | j  | j   d S(   s@   
        Create a server, report its address and run it
        s   manager serving at %rN(   RZ   t   _ServerR-   R!   Rp   R   Rr   (	   t   clsRV   R!   RW   Ra   R   R   R   t   server(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    
c         O@  s   |  j  j t j k s! t d   |  j |  j d |  j } z) t | d d | f | |  \ } } Wd | j
   Xt | |  j |  | f S(   sP   
        Create a new shared object; return the token and exposed tuple
        s   server not yet startedRW   RJ   N(   R   R   R   R   R9   R   R   R   R6   RZ   Rp   R   (   R#   R    R2   R3   R   R"   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   _create   s    !c         C@  s   |  j  j |  d S(   sC   
        Join the manager process (if it has been spawned)
        N(   R   R   (   R#   t   timeout(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   -  s    c         C@  sA   |  j  |  j d |  j } z t | d d  SWd | j   Xd S(   sS   
        Return some info about the servers shared objects and connections
        RW   RM   N(   R   R   R   R6   RZ   Rp   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   _debug_info3  s    c         C@  sA   |  j  |  j d |  j } z t | d d  SWd | j   Xd S(   s5   
        Return the number of shared objects
        RW   RN   N(   R   R   R   R6   RZ   Rp   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   _number_of_objects=  s    c         C@  s   |  S(   N(    (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt	   __enter__G  s    c         C@  s   |  j    d  S(   N(   RI   (   R#   t   exc_typet   exc_valt   exc_tb(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __exit__J  s    c         C@  s  |  j    r t d  y8 | | d | } z t | d d  Wd | j   XWn t k
 ra n X|  j d d  |  j    r t d  t |  d  r t d	  |  j   |  j d d
  |  j    r t d  q q q n  t	 j
 | _ y t j | =Wn t k
 r
n Xd S(   sQ   
        Shutdown the manager process; will be registered as a finalizer
        s#   sending shutdown message to managerRW   RI   NR   g?s   manager still aliveR   s'   trying to `terminate()` manager processg?s#   manager still alive after terminate(   t   is_aliveR   R6   RZ   Rp   Rv   R   t   hasattrR   R   R   R   R   t   _address_to_localt   KeyError(   t   processR!   RW   R&   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   M  s.    



c         C@  s   |  j  S(   N(   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   <lambda>m  t    c   
      @  s$  d |  j  k r$ |  j j   |  _ n    d k r9 t   n  | pN t   d d  } | pf t   d d  } | r xa t |  D]P \ } } t |  t k s t	 d |   t |  t k s| t	 d |   q| Wn  | | |   f |  j  <| r    f d   }	  |	 _
 t |   |	  n  d S(   s9   
        Register a typeid with the manager type
        R   t	   _exposed_t   _method_to_typeid_s   %r is not a stringc      	   @  s   t  j d   |  j  | |  \ } }   | |  j d |  d |  j d | } |  j | j d |  j } t | d  d | j	 f  | S(   Ns)   requesting creation of a shared %r objectt   managerRW   R   RQ   (
   R   R|   R   R   R   R   R!   R6   RZ   R"   (   R#   R2   R3   R   t   expt   proxyR   (   R   R    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRB     s    N(   t   __dict__R   t   copyRZ   t	   AutoProxyR?   R	   R7   R8   R9   R)   t   setattr(
   R   R    R@   R   R   R   t   create_methodt   keyR   RB   (    (   R   R    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   registero  s     	")
	N(    (    (   R)   R*   R+   R   RH   R   RZ   R$   R   R   R   Rm   t   classmethodR   R   R   R   R   R   R   t   staticmethodR   t   propertyR!   Rk   R   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s*   
				$		
	
		 	t   ProcessLocalSetc           B@  s   e  Z d    Z d   Z RS(   c         C@  s   t  j |  d    d  S(   Nc         S@  s
   |  j    S(   N(   t   clear(   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     R   (   R   t   register_after_fork(   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$     s    c         C@  s   t  |   d f S(   N(    (   R7   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    (   R)   R*   R$   R   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s   	c           B@  s   e  Z d  Z i  Z e j   Z d d d e d  Z	 d   Z
 d i  d  Z d   Z d   Z e d    Z d   Z d   Z d	   Z d
   Z d   Z RS(   s.   
    A base for proxies of shared objects
    c         C@  s;  t  j j   zP t  j j | j d   } | d  k r\ t j   t	   f } | t  j | j <n  Wd  t  j j
   X| d |  _ | d |  _ | |  _ |  j j |  _ | |  _ | |  _ t | d |  _ | d  k	 r t |  |  _ n0 |  j d  k	 r|  j j |  _ n t   j |  _ | r$|  j   n  t j |  t  j  d  S(   Ni    i   (   R   t   _mutext   acquireR   R   R!   RZ   R   t   ForkAwareLocalR   t   releaset   _tlst   _idsett   _tokenR"   t   _idt   _managerR   RX   R   R   R   R   RW   t   _increfR   t   _after_fork(   R#   R   Ra   R   RW   R   RP   t	   tls_idset(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$     s,    			c         C@  s   t  j d  t   j } t j   j d k rH | d t j   j 7} n  |  j |  j j d |  j	 } t
 | d  d | f  | |  j _ d  S(   Ns   making connection to managert
   MainThreadt   |RW   RK   (   R   R|   R   RC   R]   R}   R   R   R!   R   R6   RZ   R   R   (   R#   RC   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   _connect  s    c      	   C@  s5  y |  j  j } Wn@ t k
 rR t j d t j   j  |  j   |  j  j } n X| j	 |  j
 | | | f  | j   \ } } | d k r | S| d k r"| \ } } |  j j | j d }	 |	 | |  j d |  j d |  j d | }
 |  j | j d |  j } t | d	 d | j f  |
 St | |   d	 S(
   sW   
        Try to call a method of the referrent and return a copy of the result
        s#   thread %r does not own a connections   #RETURNs   #PROXYiR   RW   R   RQ   N(   R   R   R~   R   R|   R]   R}   RC   R   R-   R   R.   R   R   R    R   R   R   R!   R6   RZ   R"   R/   (   R#   R1   R2   R3   R   R4   R5   R   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   _callmethod  s*    	
c         C@  s   |  j  d  S(   s9   
        Get a copy of the value of the referent
        s	   #GETVALUE(   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt	   _getvalue  s    c      
   C@  s   |  j  |  j j d |  j } t | d  d |  j f  t j d |  j j	  |  j
 j |  j  |  j or |  j j } t |  t j d |  j |  j | |  j |  j
 |  j  f d d |  _ d  S(   NRW   RP   s	   INCREF %rR2   R   i
   (   R   R   R!   R   R6   RZ   R   R   R|   R"   R   t   addR   R   R   R   t   _decrefR   t   _close(   R#   R   R&   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   | j  |  j  | d  k s. | j t j k r yE t j d |  j  | |  j d | } t	 | d  d |  j f  Wq t
 k
 r } t j d |  q Xn t j d |  j  | r t | d  r t j d t j   j  | j j   | ` n  d  S(   Ns	   DECREF %rRW   RQ   s   ... decref failed %ss%   DECREF %r -- manager already shutdownR   s-   thread %r has no more proxies so closing conn(   t   discardR"   RZ   R   R   R   R   R|   R!   R6   Rv   R   R]   R}   RC   R   Rp   (   R   RW   R&   t   tlst   idsetR   R   R{   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    	c         C@  s>   d  |  _ y |  j   Wn  t k
 r9 } t d |  n Xd  S(   Ns   incref failed: %s(   RZ   R   R   Rv   R   (   R#   R{   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   -  s
    	c         C@  s   i  } t  j   r" |  j | d <n  t |  d t  r] |  j | d <t t |  j |  j	 | f f St t
 |   |  j |  j	 | f f Sd  S(   NRW   t   _isautoR   (   R   t   thread_is_spawningR   R?   R   R   t   RebuildProxyR   R   R   R7   (   R#   R3   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   5  s    c         C@  s
   |  j    S(   N(   R   (   R#   t   memo(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __deepcopy__B  s    c         C@  s*   d t  |   j |  j j d t |   f S(   Ns   <%s object, typeid %r at %s>s   0x%x(   R7   R)   R   R    R"   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR(   E  s    c         C@  s8   y |  j  d  SWn  t k
 r3 t |   d  d SXd S(   sV   
        Return representation of the referent (or a fall-back if that fails)
        R(   is   ; '__str__()' failed>N(   R   Rv   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR=   I  s    N(    (   R)   R*   R+   R   R   t   ForkAwareThreadLockR   RZ   Rk   R$   R   R   R   R   R   R   R   R   R  R(   R=   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s   %								c         C@  s   t  t   d d  } | r? | j | j k r? | j | j d S| j d t  od t  t   d t  } |  | | d | | Sd S(   s   
    Function used for unpickling proxy objects.

    If possible the shared object is returned, or otherwise a proxy for it.
    Re   i    RP   t   _inheritingN(	   R?   R   RZ   R!   R[   R"   t   popRk   R   (   RD   R   Ra   R3   R   RP   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR  W  s    c         B@  s   e  |  } y | |  | f SWn e k
 r1 n Xi  } x  | D] } d | | f | Uq? We |  e f |  } | | _ | | |  | f <| S(   sC   
    Return an proxy type whose methods are given by `exposed`
    sL   def %s(self, *args, **kwds):
        return self._callmethod(%r, args, kwds)(   R   R   R7   R   R   (   RC   R   t   _cachet   dict   metht	   ProxyType(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   MakeProxyTypem  s    	c   
   	   C@  s   t  | d } | d k r\ | |  j d | } z t | d d |  f  } Wd | j   Xn  | d k r | d k	 r | j } n  | d k r t   j } n  t d |  j	 |  } | |  | d | d | d | }	 t
 |	 _ |	 S(   s*   
    Return an auto-proxy for `token`
    i   RW   RL   Ns   AutoProxy[%s]R   RP   (   RX   RZ   R!   R6   Rp   R   R   RW   R  R    Rk   R  (
   R   Ra   R   RW   R   RP   R   R   R  R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    		t	   Namespacec           B@  s   e  Z d    Z d   Z RS(   c         K@  s   |  j  j |  d  S(   N(   R   t   update(   R#   R3   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$     s    c         C@  sy   t  |  j j    } g  } x= | D]5 \ } } | j d  s" | j d | | f  q" q" W| j   d t j d |  S(   NRF   s   %s=%rs   Namespace(%s)s   , (   R   R   R	   t
   startswithRA   R   R8   R   (   R#   R	   RB   RC   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR(     s    
(   R)   R*   R$   R(   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s   	t   Valuec           B@  s>   e  Z e d   Z d   Z d   Z d   Z e e e  Z RS(   c         C@  s   | |  _  | |  _ d  S(   N(   t	   _typecodet   _value(   R#   R   R   t   lock(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$     s    	c         C@  s   |  j  S(   N(   R  (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   | |  _  d  S(   N(   R  (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s    d t  |   j |  j |  j f S(   Ns
   %s(%r, %r)(   R7   R)   R  R  (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR(     s    (	   R)   R*   Rk   R$   R   R   R(   R   R   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s
   			c         C@  s   t  j  |  |  S(   N(   R   (   R   t   sequenceR  (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   Array  s    t   IteratorProxyc           B@  s`   e  Z e j d  d k r" d Z n d Z d   Z d   Z d	   Z d
   Z	 d   Z
 d   Z RS(   i    i   t   __next__R-   t   throwRp   t   nextc         G@  s   |  j  d |  S(   NR  (   R   (   R#   R2   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s    c         C@  s   |  S(   N(    (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __iter__  s    c         G@  s   |  j  d |  S(   NR  (   R   (   R#   R2   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s    c         G@  s   |  j  d |  S(   NR-   (   R   (   R#   R2   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR-     s    c         G@  s   |  j  d |  S(   NR  (   R   (   R#   R2   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s    c         G@  s   |  j  d |  S(   NRp   (   R   (   R#   R2   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRp     s    (   R  R-   R  Rp   (   R  R  R-   R  Rp   (   R)   R*   R   t   version_infot   _exposedR   R  R  R  R-   R  Rp   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s   						t   AcquirerProxyc           B@  s5   e  Z d Z e d  Z d   Z d   Z d   Z RS(   R   R   c         C@  s   |  j  d | f  S(   NR   (   R   (   R#   t   blocking(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   |  j  d  S(   NR   (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   |  j  d  S(   NR   (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   |  j  d  S(   NR   (   R   (   R#   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    (   R   R   (   R)   R*   R   Rk   R   R   R   R   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR    s
   		t   ConditionProxyc           B@  s8   e  Z d	 Z d
 d  Z d   Z d   Z d
 d  Z RS(   R   R   t   waitt   notifyt
   notify_allc         C@  s   |  j  d | f  S(   NR"  (   R   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR"    s    c         C@  s   |  j  d  S(   NR#  (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR#    s    c         C@  s   |  j  d  S(   NR$  (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR$    s    c         C@  s   |   } | r | S| d  k	 r/ t   | } n d  } d  } xL | s | d  k	 rp | t   } | d k rp Pqp n  |  j |  |   } q> W| S(   Ni    (   RZ   R
   R"  (   R#   t	   predicateR   R5   t   endtimet   waittime(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   wait_for  s    		(   R   R   R"  R#  R$  N(   R)   R*   R   RZ   R"  R#  R$  R(  (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR!    s
   		t
   EventProxyc           B@  s5   e  Z d Z d   Z d   Z d   Z d	 d  Z RS(
   t   is_setR   R   R"  c         C@  s   |  j  d  S(   NR*  (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR*    s    c         C@  s   |  j  d  S(   NR   (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   |  j  d  S(   NR   (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR     s    c         C@  s   |  j  d | f  S(   NR"  (   R   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR"    s    (   R*  R   R   R"  N(   R)   R*   R   R*  R   R   RZ   R"  (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR)    s
   			t   NamespaceProxyc           B@  s)   e  Z d Z d   Z d   Z d   Z RS(   t   __getattribute__t   __setattr__t   __delattr__c         C@  sB   | d d k r  t  j |  |  St  j |  d  } | d | f  S(   Ni    RF   R   R,  (   t   objectR,  (   R#   R   t
   callmethod(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __getattr__%  s    c         C@  sH   | d d k r# t  j |  | |  St  j |  d  } | d | | f  S(   Ni    RF   R   R-  (   R/  R-  R,  (   R#   R   R   R0  (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR-  +  s    c         C@  sB   | d d k r  t  j |  |  St  j |  d  } | d | f  S(   Ni    RF   R   R.  (   R/  R.  R,  (   R#   R   R0  (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR.  1  s    (   R,  R-  R.  (   R)   R*   R   R1  R-  R.  (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR+  "  s   		t
   ValueProxyc           B@  s/   e  Z d Z d   Z d   Z e e e  Z RS(   R   R   c         C@  s   |  j  d  S(   NR   (   R   (   R#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   ;  s    c         C@  s   |  j  d | f  S(   NR   (   R   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   >  s    (   R   R   (   R)   R*   R   R   R   R   R   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR2  8  s   		t   BaseListProxyt   __add__t   __contains__t   __delitem__t   __delslice__t   __getitem__t   __getslice__t   __len__t   __mul__t   __reversed__t   __rmul__t   __setitem__t   __setslice__RA   t   countt   extendt   indext   insertR	  t   removet   reverseR   t   __imul__t	   ListProxyc           B@  s   e  Z d    Z d   Z RS(   c         C@  s   |  j  d | f  |  S(   NRA  (   R   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   __iadd__N  s    c         C@  s   |  j  d | f  |  S(   NRF  (   R   (   R#   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRF  R  s    (   R)   R*   RH  RF  (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyRG  L  s   	t	   DictProxyR   R   R   t   has_keyt   popitemt
   setdefaultR  t
   ArrayProxyt	   PoolProxyt   applyt   apply_asyncRp   t   imapt   imap_unorderedR   t   mapt	   map_asynct   starmapt   starmap_asyncR   t   AsyncResultt   Iteratorc           B@  s   e  Z d  Z RS(   s!  
    Subclass of `BaseManager` which supports a number of shared object types.

    The types registered are those intended for the synchronization
    of threads, plus `dict`, `list` and `Namespace`.

    The `billiard.Manager()` function creates started instances of
    this class.
    (   R)   R*   R+   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyR   t  s   	R   t   JoinableQueuet   Eventt   LockR^   t	   Semaphoret   BoundedSemaphoret	   ConditionR   R   R   R  R   R   (Y   t
   __future__R    R   R]   R   R   R   R   R   R   R   R   R   R   t   fiveR   R	   R
   R   R   t   forkingR   R   t	   reductionR   R   R   R   t   __all__R   R   RC   R7   R?   t
   view_typesR   R   t	   view_typet   copyregt   ImportErrorR   R/  R   R6   R/   Rv   R:   RE   RG   RH   R   Rb   Rc   t   XmlListenert	   XmlClientRX   R   R   R   R   R  R  RZ   Rk   R   R  R  R  R  R  R!  R)  R+  R2  R3  RG  RI  RM  RN  R   R   RZ  R[  R^   R\  R]  R^  R   R   (    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/managers.pyt   <module>
   s   .	1		
		 "
	