U
    8d                     @   s*   d Z ddlZddlZG dd dejZdS )zIEnhanced Thread with support for return values and exception propagation.    Nc                   @   sD   e Zd ZdZddddi fddZdd Zdd	 Zd
d Zdd ZdS )REThreadz4Thread with return values and exception propagation.N c                 C   s8   t j| ||||| || _|| _|| _d| _d| _dS )z<Initialize Thread, identical to threading.Thread.__init__().N)	threadingThread__init___REThread__target_REThread__args_REThread__kwargs_retval
_exception)selfgrouptargetnameargskwargsr   r   1/usr/lib/python3/dist-packages/apport/REThread.pyr      s    zREThread.__init__c                 C   s<   | j r8z| j | j| j| _W n   tr2t | _Y nX dS )z9Run target function, identical to threading.Thread.run().N)r   r   r	   r
   sysexc_infor   r   r   r   r   run   s    zREThread.runc                 C   s   |   rt| jrt| jS )zReturn value from target function.

        This can only be called after the thread has finished, i. e. when
        is_alive() is False and did not terminate with an exception.
        )Zis_aliveAssertionErrorr   r
   r   r   r   r   return_value&   s    
zREThread.return_valuec                 C   s   | j S )zAReturn (type, value, traceback) of the exception caught in run().)r   r   r   r   r   r   0   s    zREThread.exc_infoc                 C   s4   | j r0tjdkr(| j d | j d ntd dS )zbRaise the exception caught in the thread.

        Do nothing if no exception was caught.
        3      z@raise self._exception[0], self._exception[1], self._exception[2]N)r   r   versionwith_tracebackexecr   r   r   r   	exc_raise5   s    
zREThread.exc_raise)	__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r      s   


r   )r#   r   r   r   r   r   r   r   r   <module>   s   