o
    Vh                     @   s@   d Z ddlZddlZddlmZ ddlmZ G dd deZ	dS )z*Module containing the SessionThread class.    N   )queuec                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )SessionThreadc                 C   s$   || _ || _|   || _|| _d S N)_session_jobs_create_worker
_responses_exceptions)selfinitialized_session	job_queueresponse_queueexception_queue r   u/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/requests_toolbelt/threaded/thread.py__init__   s
   
zSessionThread.__init__c                 C   s4   t j| jt d| _d| j_d| j_| j  d S )N)targetnameTr   )		threadingThread_make_requestuuiduuid4_workerdaemon_statestartr   r   r   r   r      s   zSessionThread._create_workerc              
   C   s   z?z| j jdi |}W n tjy' } z| j||f W Y d }~nd }~ww | j||f W | j  d S W | j  d S | j  w )Nr   )	r   requestexcRequestExceptionr
   putr	   r   	task_done)r   kwargsresponseer   r   r   _handle_request   s   zSessionThread._handle_requestc                 C   s4   	 z| j  }W n tjy   Y d S w | | qr   )r   
get_nowaitr   Emptyr'   )r   r$   r   r   r   r   &   s   
zSessionThread._make_requestc                 C   s
   | j  S )z*Proxy to the thread's ``is_alive`` method.)r   is_aliver   r   r   r   r*   /   s   
zSessionThread.is_alivec                 C   s   | j   dS )z&Join this thread to the master thread.N)r   joinr   r   r   r   r+   3   s   zSessionThread.joinN)	__name__
__module____qualname__r   r   r'   r   r*   r+   r   r   r   r   r   
   s    	
	r   )
__doc__r   r   requests.exceptions
exceptionsr    _compatr   objectr   r   r   r   r   <module>   s    