3 P\@s>dZddlZddlZddljZddlmZGdddeZ dS)z*Module containing the SessionThread class.N)queuec@s<eZdZddZddZddZddZd d Zd d Zd S) SessionThreadcCs$||_||_|j||_||_dS)N)_session_jobs_create_worker _responses _exceptions)selfZinitialized_sessionZ job_queueZresponse_queueZexception_queuer /usr/lib/python3.6/thread.py__init__ s zSessionThread.__init__cCs4tj|jtjd|_d|j_d|j_|jjdS)N)targetnameTr) threadingZThread _make_requestuuidZuuid4_workerZdaemonZ_statestart)r r r r rs zSessionThread._create_workercCsnz\y|jjf|}Wn4tjk rH}z|jj||fWYdd}~XnX|jj||fWd|jjXdS)N) rZrequestexcZRequestExceptionr ZputrrZ task_done)r kwargsZresponseer r r _handle_requests "zSessionThread._handle_requestc Cs<x6y|jj}Wntjk r(PYnX|j|qWdS)N)rZ get_nowaitrZEmptyr)r rr r r r&s zSessionThread._make_requestcCs |jjS)z*Proxy to the thread's ``is_alive`` method.)ris_alive)r r r r r/szSessionThread.is_alivecCs|jjdS)z&Join this thread to the master thread.N)rjoin)r r r r r3szSessionThread.joinN) __name__ __module__ __qualname__r rrrrrr r r r r s    r) __doc__rrZrequests.exceptions exceptionsrZ_compatrobjectrr r r r s