ó
*} Uc           @   s   d  Z  d d d d d d d g Z d Z d e f d
     YZ i  d  Z d   Z d   Z d   Z d d  Z
 d e f d     YZ e a e a d   Z d S(   s  Drop-in replacement for the thread module.

Meant to be used as a brain-dead substitute so that threaded code does
not need to be rewritten for when the thread module is not present.

Suggested usage is::

    try:
        try:
            import _thread  # Python >= 3
        except:
            import thread as _thread  # Python < 3
    except ImportError:
        import _dummy_thread as _thread

t   errort   start_new_threadt   exitt	   get_identt   allocate_lockt   interrupt_maint   LockTypei   i   c           B   s   e  Z d  Z d   Z RS(   s&   Dummy implementation of _thread.error.c         G   s   | |  _  d  S(   N(   t   args(   t   selfR   (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyt   __init__!   s    (   t   __name__t
   __module__t   __doc__R	   (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR       s   c         C   sş   t  |  t  t    k r* t d   n  t  |  t  t    k rT t d   n  t a y |  | |   Wn- t k
 r~ n d d l } | j   n Xt	 a t
 rś t a
 t  n  d S(   sć  Dummy implementation of _thread.start_new_thread().

    Compatibility is maintained by making sure that ``args`` is a
    tuple and ``kwargs`` is a dictionary.  If an exception is raised
    and it is SystemExit (which can be done by _thread.exit()) it is
    caught and nothing is done; all other exceptions are printed out
    by using traceback.print_exc().

    If the executed function calls interrupt_main the KeyboardInterrupt will be
    raised when the function returns.

    s   2nd arg must be a tuples   3rd arg must be a dicti˙˙˙˙N(   t   typet   tuplet	   TypeErrort   dictt   Falset   _maint
   SystemExitt	   tracebackt	   print_exct   Truet
   _interruptt   KeyboardInterrupt(   t   functionR   t   kwargsR   (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR   $   s     c           C   s
   t   d S(   s'   Dummy implementation of _thread.exit().N(   R   (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR   D   s    c           C   s   d S(   sô   Dummy implementation of _thread.get_ident().

    Since this module should only be used when _threadmodule is not
    available, it is safe to assume that the current process is the
    only thread.  Thus a constant can be safely returned.
    i˙˙˙˙(    (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR   H   s    c           C   s   t    S(   s0   Dummy implementation of _thread.allocate_lock().(   R   (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR   Q   s    c         C   s   |  d k	 r t d   n  d S(   s-   Dummy implementation of _thread.stack_size().s'   setting thread stack size not supportedi    N(   t   NoneR    (   t   size(    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyt
   stack_sizeU   s    c           B   sG   e  Z d  Z d   Z d d d  Z e Z d   Z d   Z d   Z	 RS(   s  Class implementing dummy implementation of _thread.LockType.

    Compatibility is maintained by maintaining self.locked_status
    which is a boolean that stores the state of the lock.  Pickling of
    the lock, though, should not be done since if the _thread module is
    then used with an unpickled ``lock()`` from here problems could
    occur from this class not having atomic methods.

    c         C   s   t  |  _ d  S(   N(   R   t   locked_status(   R   (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR	   f   s    i˙˙˙˙c         C   se   | d k s | r t |  _ t S|  j s5 t |  _ t S| d k r] d d l } | j |  n  t Sd S(   sŠ  Dummy implementation of acquire().

        For blocking calls, self.locked_status is automatically set to
        True and returned appropriately based on value of
        ``waitflag``.  If it is non-blocking, then the value is
        actually checked and not set if it is already acquired.  This
        is all done so that threading.Condition's assert statements
        aren't triggered and throw a little fit.

        i    i˙˙˙˙N(   R   R   R   t   timet   sleepR   (   R   t   waitflagt   timeoutR   (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyt   acquirei   s    			c         C   s   |  j    d  S(   N(   t   release(   R   t   typt   valt   tb(    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyt   __exit__   s    c         C   s   |  j  s t  n  t |  _  t S(   s   Release the dummy lock.(   R   R    R   R   (   R   (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR$      s    			c         C   s   |  j  S(   N(   R   (   R   (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyt   locked   s    N(
   R
   R   R   R	   R   R#   t	   __enter__R(   R$   R)   (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR   [   s   					c           C   s   t  r t  n t a d S(   s^   Set _interrupt flag to True to have start_new_thread raise
    KeyboardInterrupt upon exiting.N(   R   R   R   R   (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyR      s    	NI       (   R   t   __all__t   TIMEOUT_MAXt	   ExceptionR    R   R   R   R   R   R   t   objectR   R   R   R   R   R   (    (    (    s:   lib/python2.7/site-packages/functools32/_dummy_thread32.pyt   <module>   s    				8