ó
O'—^c           @@  sÕ  d  d l  m Z d  d l Z d  d l Z d d l m Z m Z d d l m Z d d l	 m
 Z
 d d l m Z d d	 d
 d d d g Z i e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6e j d 6Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d d  „ Z" d! „  Z# d" „  Z$ d# „  Z% d$ Z& i  Z' e j( ƒ  Z) d% e* f d& „  ƒ  YZ+ d' e+ f d( „  ƒ  YZ, d) e+ f d* „  ƒ  YZ- d+ e- f d, „  ƒ  YZ. d S(-   i    (   t   absolute_importNi   (   t   heapt   RLock(   t	   int_types(   t   assert_spawning(   t   ForkingPicklert   RawValuet   RawArrayt   Valuet   Arrayt   copyt   synchronizedt   ct   ut   bt   Bt   ht   Ht   it   It   lt   Lt   ft   dc         C@  s.   t  j |  ƒ } t j | ƒ } t |  | d  ƒ S(   N(   t   ctypest   sizeofR   t   BufferWrappert   rebuild_ctypet   None(   t   type_t   sizet   wrapper(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt
   _new_value   s    c         G@  sT   t  j |  |  ƒ } t | ƒ } t j t j | ƒ d t j | ƒ ƒ | j | Œ  | S(   s>   
    Returns a ctypes object allocated from shared memory
    i    (   t   typecode_to_typet   getR    R   t   memsett	   addressofR   t   __init__(   t   typecode_or_typet   argsR   t   obj(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR   %   s
    %c         C@  s‘   t  j |  |  ƒ } t | t ƒ r` | | } t | ƒ } t j t j | ƒ d t j | ƒ ƒ | S| t	 | ƒ } t | ƒ } | j
 | Œ  | Sd S(   s=   
    Returns a ctypes array allocated from shared memory
    i    N(   R!   R"   t
   isinstanceR   R    R   R#   R$   R   t   lenR%   (   R&   t   size_or_initializerR   R(   t   result(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR   0   s    
%c         O@  s£   | j  d d ƒ } | r7 t d t | j ƒ  ƒ ƒ ‚ n  t |  | Œ } | t k rV | S| t d f k rt t ƒ  } n  t	 | d ƒ s– t
 d | ƒ ‚ n  t | | ƒ S(   s6   
    Return a synchronization wrapper for a Value
    t   locks$   unrecognized keyword argument(s): %st   acquires   '%r' has no method 'acquire'N(   t   popR   t
   ValueErrort   listt   keysR   t   Falset   TrueR   t   hasattrt   AttributeErrorR   (   R&   R'   t   kwdsR-   R(   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR   A   s    c         K@  s£   | j  d d ƒ } | r7 t d t | j ƒ  ƒ ƒ ‚ n  t |  | ƒ } | t k rV | S| t d f k rt t ƒ  } n  t	 | d ƒ s– t
 d | ƒ ‚ n  t | | ƒ S(   s9   
    Return a synchronization wrapper for a RawArray
    R-   s$   unrecognized keyword argument(s): %sR.   s   '%r' has no method 'acquire'N(   R/   R   R0   R1   R2   R   R3   R4   R   R5   R6   R   (   R&   R+   R7   R-   R(   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR	   S   s    c         C@  s)   t  t |  ƒ ƒ } |  t j | ƒ d <| S(   Ni    (   R    t   typeR   t   pointer(   R(   t   new_obj(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR
   e   s    c         C@  s  t  |  t ƒ s t d ƒ ‚ t  |  t j ƒ r; t |  | ƒ St  |  t j ƒ ry |  j t j k rl t	 |  | ƒ St
 |  | ƒ St |  ƒ } y t | } Wnq t k
 rg  | j D] } | d ^ q­ } t d „  | Dƒ ƒ } d | j } t | t f | ƒ } t | <n X| |  | ƒ Sd  S(   Ns   object already synchronizedi    c         s@  s!   |  ] } | t  | ƒ f Vq d  S(   N(   t   make_property(   t   .0t   name(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pys	   <genexpr>z   s    t   Synchronized(   R)   t   SynchronizedBaset   AssertionErrorR   t   _SimpleCDataR>   R	   t   _type_t   c_chart   SynchronizedStringt   SynchronizedArrayR8   t   class_cachet   KeyErrort   _fields_t   dictt   __name__(   R(   R-   t   clst   sclst   fieldt   namesR   t	   classname(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR   k   s      !c         C@  sX   t  |  ƒ t |  t j ƒ r8 t |  j |  j |  j f f St t |  ƒ |  j d  f f Sd  S(   N(
   R   R)   R   R	   R   RB   t   _wrappert   _length_R8   R   (   R(   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   reduce_ctype„   s    
c         C@  sK   | d  k	 r |  | }  n  t j |  t ƒ |  j | j ƒ  ƒ } | | _ | S(   N(   R   R   t   registerRR   t   from_addresst   get_addressRP   (   R   R   t   lengthR(   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR   Œ   s    	c         B@  sP   y e  |  SWn= e k
 rK i  } e |  f d | U| |  e  |  <| |  SXd  S(   Ni   (   t
   prop_cacheRG   t   template(   R=   R   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR;   ™   s    sÿ   
def get%s(self):
    self.acquire()
    try:
        return self._obj.%s
    finally:
        self.release()
def set%s(self, value):
    self.acquire()
    try:
        self._obj.%s = value
    finally:
        self.release()
%s = property(get%s, set%s)
R?   c           B@  s8   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z RS(   c         C@  s=   | |  _  | p t ƒ  |  _ |  j j |  _ |  j j |  _ d  S(   N(   t   _objR   t   _lockR.   t   release(   t   selfR(   R-   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR%   ¼   s    	c         C@  s    t  |  ƒ t |  j |  j f f S(   N(   R   R   RY   RZ   (   R\   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt
   __reduce__Â   s    
c         C@  s   |  j  S(   N(   RY   (   R\   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   get_objÆ   s    c         C@  s   |  j  S(   N(   RZ   (   R\   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   get_lockÉ   s    c         C@  s   d t  |  ƒ j |  j f S(   Ns   <%s wrapper for %s>(   R8   RJ   RY   (   R\   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   __repr__Ì   s    N(   RJ   t
   __module__R   R%   R]   R^   R_   R`   (    (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR?   º   s
   			R>   c           B@  s   e  Z e d  ƒ Z RS(   t   value(   RJ   Ra   R;   Rb   (    (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyR>   Ð   s   RE   c           B@  s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C@  s   t  |  j ƒ S(   N(   R*   RY   (   R\   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   __len__Ö   s    c         C@  s+   |  j  ƒ  z |  j | SWd  |  j ƒ  Xd  S(   N(   R.   RY   R[   (   R\   R   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   __getitem__Ù   s    
c         C@  s-   |  j  ƒ  z | |  j | <Wd  |  j ƒ  Xd  S(   N(   R.   RY   R[   (   R\   R   Rb   (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   __setitem__à   s    
c         C@  s.   |  j  ƒ  z |  j | | !SWd  |  j ƒ  Xd  S(   N(   R.   RY   R[   (   R\   t   startt   stop(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   __getslice__ç   s    
c         C@  s0   |  j  ƒ  z | |  j | | +Wd  |  j ƒ  Xd  S(   N(   R.   RY   R[   (   R\   Rf   Rg   t   values(    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   __setslice__î   s    
(   RJ   Ra   Rc   Rd   Re   Rh   Rj   (    (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyRE   Ô   s
   				RD   c           B@  s    e  Z e d  ƒ Z e d ƒ Z RS(   Rb   t   raw(   RJ   Ra   R;   Rb   Rk   (    (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyRD   ö   s   (/   t
   __future__R    R   t   weakreft    R   R   t   fiveR   t   forkingR   t	   reductionR   t   __all__RC   t   c_wchart   c_bytet   c_ubytet   c_shortt   c_ushortt   c_intt   c_uintt   c_longt   c_ulongt   c_floatt   c_doubleR!   R    R   R   R   R	   R
   R   R   RR   R   R;   RX   RW   t   WeakKeyDictionaryRF   t   objectR?   R>   RE   RD   (    (    (    s7   /tmp/pip-unpacked-wheel-40MfcW/billiard/sharedctypes.pyt   <module>	   s>   									"