ó
xFWgc           @   s¥   d  Z  d d d d d d d g Z d d	 l 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:
        import thread
    except ImportError:
        import dummy_thread as thread

t   errort   start_new_threadt   exitt	   get_identt   allocate_lockt   interrupt_maint   LockTypeiÿÿÿÿNc           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"   /usr/lib/python2.7/dummy_thread.pyt   __init__   s    (   t   __name__t
   __module__t   __doc__R	   (    (    (    s"   /usr/lib/python2.7/dummy_thread.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 t 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 dictN(   t   typet   tuplet	   TypeErrort   dictt   Falset   _maint
   SystemExitt
   _tracebackt	   print_exct   Truet
   _interruptt   KeyboardInterrupt(   t   functionR   t   kwargs(    (    s"   /usr/lib/python2.7/dummy_thread.pyR      s    c           C   s
   t  ‚ d S(   s&   Dummy implementation of thread.exit().N(   R   (    (    (    s"   /usr/lib/python2.7/dummy_thread.pyR   :   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"   /usr/lib/python2.7/dummy_thread.pyR   >   s    c           C   s   t  ƒ  S(   s/   Dummy implementation of thread.allocate_lock().(   R   (    (    (    s"   /usr/lib/python2.7/dummy_thread.pyR   G   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"   /usr/lib/python2.7/dummy_thread.pyt
   stack_sizeK   s    c           B   sD   e  Z d  Z d „  Z 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"   /usr/lib/python2.7/dummy_thread.pyR	   \   s    c         C   s=   | d k s | r t |  _ t S|  j s5 t |  _ t St 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.

        N(   R   R   R   R   (   R   t   waitflag(    (    s"   /usr/lib/python2.7/dummy_thread.pyt   acquire_   s    			c         C   s   |  j  ƒ  d  S(   N(   t   release(   R   t   typt   valt   tb(    (    s"   /usr/lib/python2.7/dummy_thread.pyt   __exit__v   s    c         C   s   |  j  s t ‚ n  t |  _  t S(   s   Release the dummy lock.(   R   R    R   R   (   R   (    (    s"   /usr/lib/python2.7/dummy_thread.pyR!   y   s    			c         C   s   |  j  S(   N(   R   (   R   (    (    s"   /usr/lib/python2.7/dummy_thread.pyt   locked‚   s    N(
   R
   R   R   R	   R   R    t	   __enter__R%   R!   R&   (    (    (    s"   /usr/lib/python2.7/dummy_thread.pyR   Q   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"   /usr/lib/python2.7/dummy_thread.pyR   Š   s    	(   R   t   __all__t	   tracebackR   t	   ExceptionR    R   R   R   R   R   R   t   objectR   R   R   R   R   R   (    (    (    s"   /usr/lib/python2.7/dummy_thread.pyt   <module>   s   				5