ó
ú2ec           @   sm   d  Z  d d l Z y d d l Z Wn e k
 rA e d ƒ ‚ n Xe e d ƒ s` e d ƒ ‚ n  d „  Z d S(   sB   
Kill a thread, from http://sebulba.wikispaces.com/recipe+thread2
iÿÿÿÿNs=   You cannot use paste.util.killthread without ctypes installedt	   pythonapis=   You cannot use paste.util.killthread without ctypes.pythonapic         C   sÂ   t  | t j t f ƒ s' t d ƒ ‚ n  t  |  t ƒ sE t d ƒ ‚ n  t j j t j	 |  ƒ t j
 | ƒ ƒ } | d k r‡ t d ƒ ‚ n7 | d k r¾ t j j t j	 |  ƒ d ƒ t d ƒ ‚ n  d S(   s˜   raises the exception, performs cleanup if needed.

    tid is the value given by thread.get_ident() (an integer).
    Raise SystemExit to kill a thread.s(   Only types can be raised (not instances)s   tid must be an integeri    s   invalid thread idi   s    PyThreadState_SetAsyncExc failedN(   t
   isinstancet   sixt   class_typest   typet	   TypeErrort   intt   ctypesR    t   PyThreadState_SetAsyncExct   c_longt	   py_objectt
   ValueErrort   SystemError(   t   tidt   exctypet   res(    (    s?   /usr/local/lib/python2.7/dist-packages/paste/util/killthread.pyt   async_raise   s    '(   t   __doc__R   R   t   ImportErrort   hasattrR   (    (    (    s?   /usr/local/lib/python2.7/dist-packages/paste/util/killthread.pyt   <module>   s   