ó
čžbc           @   sĎ  d  d l  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 m	 Z	 d d d d d 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 d a e a d   Z d   Z d   Z d   Z d   Z d d  Z d   Z e j   Z e j   Z  d    Z! d!   Z" i  Z# e j   Z$ d e% f d"     YZ& d d#  Z' d$   Z( e a) e e e' e	 e d%  Z* e j+ e*  d e% f d&     YZ, d e j- f d'     YZ. d S((   i˙˙˙˙N(   t   _args_from_interpreter_flags(   t   current_processt   active_childrent	   sub_debugt   debugt   infot   sub_warningt
   get_loggert   log_to_stderrt   get_temp_dirt   register_after_forkt
   is_exitingt   Finalizet   ForkAwareThreadLockt   ForkAwareLocalt   SUBDEBUGt
   SUBWARNINGi    i   i
   i   i   t   multiprocessings+   [%(levelname)s/%(processName)s] %(message)sc         G   s    t  r t  j t |  |  n  d  S(   N(   t   _loggert   logR   (   t   msgt   args(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   D   s    c         G   s    t  r t  j t |  |  n  d  S(   N(   R   R   t   DEBUG(   R   R   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   H   s    c         G   s    t  r t  j t |  |  n  d  S(   N(   R   R   t   INFO(   R   R   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   L   s    c         G   s    t  r t  j t |  |  n  d  S(   N(   R   R   R   (   R   R   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   P   s    c          C   s×   d d l  }  d d l } |  j   zŁ t sÄ |  j t  a d t _ |  j t d  |  j t	 d  t
 | d  r | j t  | j t  qÄ | j j t d i  f  | j j t d i  f  n  Wd |  j   Xt S(	   s0   
    Returns logger used by multiprocessing
    i˙˙˙˙Ni    R   R   t
   unregister(    (    (   t   loggingt   atexitt   _acquireLockR   t	   getLoggert   LOGGER_NAMEt	   propagatet   addLevelNameR   R   t   hasattrR   t   _exit_functiont   registert   _exithandlerst   removet   appendt   _releaseLock(   R   R   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   T   s    
	 c         C   sj   d d l  } t   } | j t  } | j   } | j |  | j |  |  r` | j |   n  t a	 t
 S(   sB   
    Turn on logging and add a handler which prints to stderr
    i˙˙˙˙N(   R   R   t	   Formattert   DEFAULT_LOGGING_FORMATt   StreamHandlert   setFormattert
   addHandlert   setLevelt   Truet   _log_to_stderrR   (   t   levelR   t   loggert	   formattert   handler(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   q   s    	c          C   s   t    j d  k rw d d  l }  d d  l } | j d d  } t d |  t d  |  j d | g d d | t    _ n  t    j S(   Ni˙˙˙˙t   prefixs   pymp-s   created temp directory %sR   t   exitpriorityi˙˙˙(	   R   t   _tempdirt   Nonet   shutilt   tempfilet   mkdtempR   R   t   rmtree(   R7   R8   t   tempdir(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR	      s    c          C   sq   t  t j    }  |  j   xN |  D]F \ \ } } } } y | |  Wq# t k
 rh } t d |  q# Xq# Wd  S(   Ns    after forker raised exception %s(   t   listt   _afterfork_registryt   itemst   sortt	   ExceptionR   (   R>   t   indext   identt   funct   objt   e(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   _run_after_forkers   s    
c         C   s#   |  t  t j   t |   | f <d  S(   N(   R=   t   _afterfork_countert   nextt   id(   RD   RC   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR
   Ą   s    c           B   sG   e  Z d  Z d d d d  Z d d  Z d   Z d   Z d   Z RS(   sA   
    Class which supports object finalization using weakrefs
    c         C   sś   | d  k s* t |  t t f k s* t  | d  k	 rN t j | |   |  _ n | d  k	 s` t  | |  _ | |  _	 | p{ i  |  _
 | t j   f |  _ t j   |  _ |  t |  j <d  S(   N(   R6   t   typet   intt   longt   AssertionErrort   weakreft   reft   _weakreft	   _callbackt   _argst   _kwargst   _finalizer_counterRH   t   _keyt   ost   getpidt   _pidt   _finalizer_registry(   t   selfRD   t   callbackR   t   kwargsR4   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   __init__°   s    *		c         C   sľ   y t  |  j =Wn t k
 r+ t d  n X|  j t j   k rT t d  d } n4 t d |  j |  j	 |  j
  |  j |  j	 |  j
   } d |  _ |  _ |  _	 |  _
 |  _ | Sd S(   sQ   
        Run the callback unless it has already been called or cancelled
        s   finalizer no longer registereds+   finalizer ignored because different processs/   finalizer calling %s with args %s and kwargs %sN(   RY   RU   t   KeyErrorR   RX   RV   RW   R6   RQ   RR   RS   RP   (   RZ   t   wrt   res(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   __call__Ŕ   s    
	%c         C   sK   y t  |  j =Wn t k
 r! n& Xd |  _ |  _ |  _ |  _ |  _ d S(   s3   
        Cancel finalization of the object
        N(   RY   RU   R^   R6   RP   RQ   RR   RS   (   RZ   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   cancelÔ   s
    c         C   s   |  j  t k S(   sS   
        Return whether this finalizer is still waiting to invoke callback
        (   RU   RY   (   RZ   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   still_activeŕ   s    c         C   sŰ   y |  j    } Wn t t f k
 r/ d  } n X| d  k r@ d Sd t |  j d |  j  } |  j r | d t |  j  7} n  |  j r˘ | d t |  j  7} n  |  j	 d d  k	 rÓ | d t |  j	 d  7} n  | d S(	   Ns   <Finalize object, dead>s   <Finalize object, callback=%st   __name__s   , args=s	   , kwargs=i    s   , exitprority=t   >(
   RP   t   AttributeErrort	   TypeErrorR6   t   getattrRQ   RR   t   strRS   RU   (   RZ   RD   t   x(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   __repr__ć   s    
		(    N(	   Rd   t
   __module__t   __doc__R6   R]   Ra   Rb   Rc   Rk   (    (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   Ź   s   		c            sč   t  d k r d S  d k r( d   } n   f d   } g  t  j   D] } | |  rD | ^ qD } | j d t  xV | D]N \ } } t d |  y |   Wqy t k
 rĆ d d l } | j   qy Xqy W  d k rä t  j	   n  d S(   sŕ   
    Run all finalizers whose exit priority is not None and at least minpriority

    Finalizers with highest priority are called first; finalizers with
    the same priority will be called in reverse order of creation.
    Nc         S   s   |  d d d  k	 S(   Ni    (   R6   (   t   p(    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   <lambda>  t    c            s&   |  d d d  k	 o% |  d d   k S(   Ni    (   R6   (   Rn   (   t   minpriority(    s*   /usr/lib/python2.7/multiprocessing/util.pyRo   
  Rp   t   reverses
   calling %si˙˙˙˙(
   RY   R6   R>   R?   R-   R   R@   t	   tracebackt	   print_exct   clear(   Rq   t   fRj   R>   t   keyt	   finalizerRs   (    (   Rq   s*   /usr/lib/python2.7/multiprocessing/util.pyt   _run_finalizersú   s     +c           C   s   t  p t  d k S(   s6   
    Returns true if the process is shutting down
    N(   t   _exitingR6   (    (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   !  s    c         C   s°   |  d  | d  | d  |   d  k	 r x: |   D]/ } | j r7 |  d | j  | j j   q7 q7 Wx. |   D]  } |  d | j  | j   qt Wn  | d  |   d  S(   Ns   process shutting downs2   running all "atexit" finalizers with priority >= 0i    s!   calling terminate() for daemon %ss   calling join() for process %ss)   running the remaining "atexit" finalizers(   R6   t	   _daemonict   namet   _popent	   terminatet   join(   R   R   Ry   R   R   Rn   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR!   )  s    	


	
c           B   s   e  Z d    Z d   Z RS(   c         C   s   |  j    t |  t j   d  S(   N(   t   _resetR
   R   (   RZ   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR]   T  s    
c         C   s1   t  j   |  _ |  j j |  _ |  j j |  _ d  S(   N(   t	   threadingt   Lockt   _lockt   acquiret   release(   RZ   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   X  s    (   Rd   Rl   R]   R   (    (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   S  s   	c           B   s   e  Z d    Z d   Z RS(   c         C   s   t  |  d    d  S(   Nc         S   s   |  j  j   S(   N(   t   __dict__Ru   (   RD   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyRo   _  Rp   (   R
   (   RZ   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR]   ^  s    c         C   s   t  |   d f S(   N(    (   RJ   (   RZ   (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt
   __reduce__`  s    (   Rd   Rl   R]   R   (    (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyR   ]  s   	(/   RV   t	   itertoolsRN   R   R   t
   subprocessR    t   multiprocessing.processR   R   t   __all__t   NOTSETR   R   R   R   R   R(   R6   R   t   FalseR.   R   R   R   R   R   R   R	   t   WeakValueDictionaryR=   t   countRG   RF   R
   RY   RT   t   objectR   Ry   R   Rz   R!   R"   R   t   localR   (    (    (    s*   /usr/lib/python2.7/multiprocessing/util.pyt   <module>#   sT   										N'		"
