o
    åvŽfõ  ã                   @   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   sH   | j r"z| j | ji | j¤Ž| _W dS    trt ¡ | _Y dS Y dS 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J ‚| jrJ ‚| jS )z»Return 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.
        )Úis_aliver   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   s6   | j rtjdkr| j d  | j d ¡‚tdƒ dS 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    