ó
O'—^c           @@  s©  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z 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 m Z dK Z d
 j e e e d d !ƒ ƒ d j e d ƒ Z d Z d Z d Z d Z d Z d Z d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 g Z  d1 „  Z! d2 Z" d3 „  Z# e$ e% e% d4 „ Z& d5 „  Z' d6 „  Z( d7 „  Z) d d8 „ Z+ d9 „  Z, d: „  Z- d; „  Z. d d< „ Z/ d d= „ Z0 d d> „ Z1 d? „  Z2 d d@ „ Z3 d dA „ Z4 d d dL d d d d d d d d d d e$ d e% e% dB „ Z5 dC „  Z6 dD „  Z7 dE „  Z8 dF „  Z9 dG „  Z: dH „  Z; dI „  Z< e j= j> dJ ƒ r¥e< e% ƒ n  d S(M   s:   Python multiprocessing fork with improvements and bugfixesi    (   t   absolute_importNi   (   t   ProcessErrort   BufferTooShortt   TimeoutErrort   AuthenticationErrort   TimeLimitExceededt   SoftTimeLimitExceededt   WorkerLostError(   t   Processt   current_processt   active_children(   t   SUBDEBUGt
   SUBWARNINGi   i   t   .i   t    s&   R Oudkerk / Python Software Foundations   python-dev@python.orgs	   Ask Solems   ask@celeryproject.orgs!   http://github.com/celery/billiardt   restructuredtextR   R	   R
   t   freeze_supportt   Managert   Pipet	   cpu_countt   log_to_stderrt
   get_loggert   allow_connection_picklingR   R   t   Lockt   RLockt	   Semaphoret   BoundedSemaphoret	   Conditiont   Eventt   Queuet   JoinableQueuet   Poolt   Valuet   Arrayt   RawValuet   RawArrayR   R   t   set_executablet   forking_enablet   forking_is_enabledc          C@  s   d d l  m }  |  ƒ  S(   Ni   (   t   ensure_multiprocessing(   t   _extR'   (   R'   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR'   <   s    sI   force_execv is not supported as the billiard C extension is not installedc          C@  s'   d d l  m }  |  ƒ  } | j ƒ  | S(   s¶   
    Returns a manager associated with a running server process

    The managers methods such as `Lock()`, `Condition()` and `Queue()`
    can be used to create shared objects.
    i   (   t   SyncManager(   t   managersR)   t   start(   R)   t   m(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   K   s    	
c         C@  s    d d l  m } | |  | | ƒ S(   s;   
    Returns two connection object connected by a pipe
    i    (   R   (   t   billiard.connectionR   (   t   duplext	   rnonblockt	   wnonblockR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   X   s    c          C@  s*  t  j d k rI y t t j d ƒ }  Wq
t t f k
 rE d }  q
XnÁ d t  j k sg t  j d k rÔ d } t  j d k r‰ d | } n  y. t j | ƒ  } t | j ƒ  ƒ }  Wd QXWq
t k
 rÐ d }  q
Xn6 y t j	 d	 ƒ }  Wn  t t
 t f k
 r	d }  n X|  d
 k r|  St d ƒ ‚ d S(   s2   
    Returns the number of CPUs in the system
    t   win32t   NUMBER_OF_PROCESSORSi    t   bsdt   darwins   /sbin/sysctl -n hw.ncpus   /usrNt   SC_NPROCESSORS_ONLNi   s   cannot determine number of cpus(   t   syst   platformt   intt   ost   environt
   ValueErrort   KeyErrort   popent   readt   sysconft   OSErrort   AttributeErrort   NotImplementedError(   t   numt   commt   p(    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   `   s*    
c          C@  s?   t  j d k r; t t  d t ƒ r; d d l m }  |  ƒ  n  d S(   sˆ   
    Check whether this is a fake forked process in a frozen executable.
    If so then run code specified by commandline and exit.
    R1   t   frozeni   (   R   N(   R6   R7   t   getattrt   Falset   forkingR   (   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   ~   s    !c          C@  s   d d l  m }  |  ƒ  S(   sR   
    Return package logger -- if it does not already exist then it is created
    i   (   R   (   t   utilR   (   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   ˆ   s    c         C@  s   d d l  m } | |  ƒ S(   sB   
    Turn on logging and add a handler which prints to stderr
    i   (   R   (   RJ   R   (   t   levelR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR      s    c          C@  s   d d l  m }  d S(   sO   
    Install support for sending connections and sockets between processes
    i   (   t	   reductionN(   R   RL   (   RL   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   ˜   s    c          C@  s   d d l  m }  |  ƒ  S(   s-   
    Returns a non-recursive lock object
    i   (   R   (   t   synchronizeR   (   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   £   s    c          C@  s   d d l  m }  |  ƒ  S(   s)   
    Returns a recursive lock object
    i   (   R   (   RM   R   (   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   «   s    c         C@  s   d d l  m } | |  ƒ S(   s$   
    Returns a condition object
    i   (   R   (   RM   R   (   t   lockR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   ³   s    c         C@  s   d d l  m } | |  ƒ S(   s$   
    Returns a semaphore object
    i   (   R   (   RM   R   (   t   valueR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   »   s    c         C@  s   d d l  m } | |  ƒ S(   s,   
    Returns a bounded semaphore object
    i   (   R   (   RM   R   (   RO   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   Ã   s    c          C@  s   d d l  m }  |  ƒ  S(   s!   
    Returns an event object
    i   (   R   (   RM   R   (   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   Ë   s    c         C@  s   d d l  m } | |  ƒ S(   s    
    Returns a queue object
    i   (   R   (   t   queuesR   (   t   maxsizeR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   Ó   s    c         C@  s   d d l  m } | |  ƒ S(   s    
    Returns a queue object
    i   (   R   (   RP   R   (   RQ   R   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   Û   s    c         C@  sJ   d d l  m } | |  | | | | | | | | |	 |
 | | | | | | ƒ S(   s'   
    Returns a process pool object
    i   (   R   (   t   poolR   (   t	   processest   initializert   initargst   maxtasksperchildt   timeoutt   soft_timeoutt   lost_worker_timeoutt   max_restartst   max_restart_freqt   on_process_upt   on_process_downt   on_timeout_sett   on_timeout_cancelt   threadst	   semaphoret   putlockst   allow_restartR   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR   ã   s    			c         G@  s   d d l  m } | |  | Œ S(   s!   
    Returns a shared object
    i   (   R"   (   t   sharedctypesR"   (   t   typecode_or_typet   argsR"   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR"   ó   s    c         C@  s   d d l  m } | |  | ƒ S(   s    
    Returns a shared array
    i   (   R#   (   Rd   R#   (   Re   t   size_or_initializerR#   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR#   û   s    c         O@  s    d d l  m } | |  | | Ž S(   s.   
    Returns a synchronized shared object
    i   (   R    (   Rd   R    (   Re   Rf   t   kwdsR    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR      s    c         K@  s    d d l  m } | |  | |  S(   s-   
    Returns a synchronized shared array
    i   (   R!   (   Rd   R!   (   Re   Rg   Rh   R!   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR!     s    c         C@  s   d d l  m } | |  ƒ d S(   s«   
    Sets the path to a python.exe or pythonw.exe binary used to run
    child processes on Windows instead of sys.executable.
    Useful for people embedding Python.
    i   (   R$   N(   RI   R$   (   t
   executableR$   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR$     s    c          C@  s   d d l  m }  |  j S(   s!  
    Returns a boolean value indicating whether billiard is
    currently set to create child processes by forking the current
    python process rather than by starting a new instances of python.

    On Windows this always returns `False`.  On Unix it returns `True` by
    default.
    i   (   RI   (   R   RI   t   _forking_is_enabled(   RI   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR&   !  s    	c         C@  s“   |  s d d l  m } | ry d d l m } |  rQ t t d ƒ rQ t d ƒ ‚ n  t |  ƒ | _ |  sŒ d t j	 d <qŒ q t
 j t t ƒ ƒ n  d S(	   sI  
    Enable/disable creation of child process by forking the current process.

    `value` should be a boolean value.  If `value` is true then
    forking is enabled.  If `value` is false then forking is disabled.
    On systems with `os.fork()` forking is enabled by default, and on
    other systems it is always disabled.
    i   (   t   supports_exec(   RI   t   forks   os.fork() not foundt   1t   MULTIPROCESSING_FORKING_DISABLEN(   R(   Rk   R   RI   t   hasattrR9   R;   t   boolRj   R:   t   warningst   warnt   RuntimeWarningt
   W_NO_EXECV(   RO   Rk   RI   (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyR%   .  s    	Rn   (   i   i   i    i   (    (?   t   __doc__t
   __future__R    R9   R6   Rq   t
   exceptionsR   R   R   R   R   R   R   t   processR   R	   R
   RJ   R   R   t   VERSIONt   joint   mapt   strt   __version__t
   __author__t   __author_email__t   __maintainer__t   __contact__t   __homepage__t   __docformat__t   __all__R'   Rt   R   t   TrueRH   R   R   R   R   t   NoneR   R   R   R   R   R   R   R   R   R   R   R"   R#   R    R!   R$   R&   R%   R:   t   get(    (    (    s3   /tmp/pip-unpacked-wheel-40MfcW/billiard/__init__.pyt   <module>   sj   4	0					
													
		