B
    `J                 @   sl   d Z ddlmZmZmZ eZddlZddlZyddl	Z
W n ek
rT   ddl
Z
Y nX G dd dejZdS )zPython threading tools.    )absolute_importdivisionprint_functionNc                   s0   e Zd ZdZ fddZdd Zdd Z  ZS )WrappedThreadz<Wrapper around Thread which captures results and exceptions.c                s(   t t|   t | _|| _d| _dS )z)
        :type action: () -> any
        N)superr   __init__queueQueue_resultactionresult)selfr   )	__class__ L/home/dcms/DCMS/lib/python3.7/site-packages/ansible_test/_internal/thread.pyr      s    
zWrappedThread.__init__c             C   s>   y| j |  df W n    | j dt f Y nX dS )z
        Run action and capture results or exception.
        Do not override. Do not call directly. Executed by the start() method.
        N)r
   putr   sysexc_info)r   r   r   r   run   s    zWrappedThread.runc             C   sD   | j  \}}|r:tjd dkr2|d |d td || _|S )zj
        Wait for thread to exit and return the result or raise an exception.
        :rtype: any
        r         z.raise exception[0], exception[1], exception[2])r
   getr   version_infowith_tracebackexecr   )r   r   	exceptionr   r   r   wait_for_result*   s    zWrappedThread.wait_for_result)__name__
__module____qualname____doc__r   r   r   __classcell__r   r   )r   r   r      s   
r   )r    
__future__r   r   r   type__metaclass__	threadingr   r	   r   ImportErrorThreadr   r   r   r   r   <module>   s   