
&]\c           @` s   d  d l  m Z m Z m Z d  d l Z d  d l Z d d d g Z d e f d     YZ	 d e
 f d     YZ d d  Z d S(	   i    (   t   divisiont   print_functiont   absolute_importNt   ReentrancyErrort   ReentrancyLockt   non_reentrantc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyR      s   c           B` s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s!  
    Threading lock that raises an exception for reentrant calls.

    Calls from different threads are serialized, and nested calls from the
    same thread result to an error.

    The object can be used as a context manager, or to decorate functions
    via the decorate() method.

    c         C` s%   t  j   |  _ t |  _ | |  _ d  S(   N(   t	   threadingt   RLockt   _rlockt   Falset   _enteredt   _err_msg(   t   selft   err_msg(    (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyt   __init__   s    	c         C` sB   |  j  j   |  j r5 |  j  j   t |  j   n  t |  _ d  S(   N(   R
   t   acquireR   t   releaseR   R   t   True(   R   (    (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyt	   __enter__    s
    	c         C` s   t  |  _ |  j j   d  S(   N(   R   R   R
   R   (   R   t   typet   valuet	   traceback(    (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyt   __exit__'   s    	c         ` s%     f d   } t  j j j | |  S(   Nc         ` s      |  | |   SWd  QXd  S(   N(    (   t   funct   at   kw(   R   (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyt   caller,   s    (   t   scipyt   _libt	   decoratort   decorate(   R   R   R   (    (   R   s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyR    +   s    (   R   R   t   __doc__R   R   R   R    (    (    (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyR      s
   
			c         ` s     f d   } | S(   sP   
    Decorate a function with a threading lock and prevent reentrant calls.
    c         ` s;     } | d  k r" d |  j } n  t |  } | j |   S(   Ns   %s is not re-entrant(   t   NoneR   R   R    (   R   t   msgt   lock(   R   (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyR   6   s
    (    (   R   R   (    (   R   s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyR   2   s    (   t
   __future__R    R   R   R   t   scipy._lib.decoratorR   t   __all__t   RuntimeErrorR   t   objectR   R"   R   (    (    (    s7   lib/python2.7/site-packages/scipy/_lib/_threadsafety.pyt   <module>   s   #