a
    ^g                     @   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)selfZinitialized_sessionZ	job_queueZresponse_queueZexception_queue r   o/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/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~   zlz| j jf i |}W n6 tjyN } z| j||f W Y d }~nd }~0 0 | j||f W | j  n| j  0 d S r   )	r   requestexcRequestExceptionr
   putr	   r   	task_done)r   kwargsresponseer   r   r   _handle_request   s    &zSessionThread._handle_requestc                 C   s8   z| j  }W n tjy&   Y q4Y n0 | | q d S 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   Zrequests.exceptions
exceptionsr   Z_compatr   objectr   r   r   r   r   <module>   s
   