Your IP : 13.59.5.179


Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/threading.cpython-36.opt-2.pyc

3

��2a���@sxddlZddlZddlmZddlmZddl	m
Z
ddlmZ
mZyddlmZWn ek
rtddlmZYnXddd	d
ddd
ddddddddddddddgZejZejZejZejZejZy
ejZWne k
r�dZYnXej!Z![da"da#dd�Z$dd�Z%eZ&dd�ZGdd �d �Z'e'Z(Gd!d	�d	�Z)Gd"d�d�Z*Gd#d�de*�Z+Gd$d�d�Z,Gd%d�d�Z-Gd&d�de.�Z/e�j0Z1e1�d?d(d)�Z2e�a3iZ4iZ5e
�Z6Gd*d�d�Z7Gd+d�de7�Z8Gd,d-�d-e7�Z9Gd.d/�d/e7�Z:d0d
�Z;e;Z<d1d�Z=e=Z>d2d3�Z?d4d�Z@dd5lmAZAe9�aBd6d7�ZCd8d9�ZDd:d�ZEydd;lmFZGWn"ek
�rjdd<lHmGZGYnXd=d>�ZIdS)@�N)�	monotonic)�
format_exc)�WeakSet)�islice�count)�deque�	get_ident�active_count�	Condition�current_thread�	enumerate�main_thread�TIMEOUT_MAX�Event�Lock�RLock�	Semaphore�BoundedSemaphore�Thread�Barrier�BrokenBarrierError�Timer�ThreadError�
setprofile�settrace�local�
stack_sizecCs|adS)N)�
_profile_hook)�func�r�./opt/alt/python36/lib64/python3.6/threading.pyr2scCs|adS)N)�_trace_hook)rrrr r<scOstdkrt||�St||�S)N)�_CRLock�_PyRLock)�args�kwargsrrr rJs	
c@sReZdZdd�Zdd�Zddd�ZeZd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_RLockcCst�|_d|_d|_dS)Nr)�_allocate_lock�_block�_owner�_count)�selfrrr �__init__asz_RLock.__init__cCs^|j}yt|j}Wntk
r(YnXd|jj�r:dnd|jj|jj||j	t
t|��fS)Nz)<%s %s.%s object owner=%r count=%d at %s>�lockedZunlocked)r)�_active�name�KeyErrorr(r-�	__class__�
__module__�__qualname__r*�hex�id)r+�ownerrrr �__repr__fsz_RLock.__repr__T�cCsDt�}|j|kr"|jd7_dS|jj||�}|r@||_d|_|S)Nr8)rr)r*r(�acquire)r+�blocking�timeout�me�rcrrr r9us
z_RLock.acquirecCs<|jt�krtd��|jd|_}|s8d|_|jj�dS)Nzcannot release un-acquired lockr8)r)r�RuntimeErrorr*r(�release)r+rrrr r?�sz_RLock.releasecCs|j�dS)N)r?)r+�t�v�tbrrr �__exit__�sz_RLock.__exit__cCs|jj�|\|_|_dS)N)r(r9r*r))r+�staterrr �_acquire_restore�s
z_RLock._acquire_restorecCs<|jdkrtd��|j}d|_|j}d|_|jj�||fS)Nrzcannot release un-acquired lock)r*r>r)r(r?)r+rr6rrr �
_release_save�s

z_RLock._release_savecCs|jt�kS)N)r)r)r+rrr �	_is_owned�sz_RLock._is_ownedN���)TrH)�__name__r2r3r,r7r9�	__enter__r?rCrErFrGrrrr r&Ws

$
r&c@speZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
ddd�Zddd�Zdd�Z
e
ZdS)r
NcCs�|dkrt�}||_|j|_|j|_y|j|_Wntk
rDYnXy|j|_Wntk
rfYnXy|j|_Wntk
r�YnXt�|_	dS)N)
r�_lockr9r?rF�AttributeErrorrErG�_deque�_waiters)r+�lockrrr r,�s$zCondition.__init__cCs
|jj�S)N)rKrJ)r+rrr rJ�szCondition.__enter__cGs|jj|�S)N)rKrC)r+r$rrr rC�szCondition.__exit__cCsd|jt|j�fS)Nz<Condition(%s, %d)>)rK�lenrN)r+rrr r7�szCondition.__repr__cCs|jj�dS)N)rKr?)r+rrr rF�szCondition._release_savecCs|jj�dS)N)rKr9)r+�xrrr rE�szCondition._acquire_restorecCs"|jjd�r|jj�dSdSdS)NrFT)rKr9r?)r+rrr rG�s
zCondition._is_ownedcCs�|j�std��t�}|j�|jj|�|j�}d}z:|dkrN|j�d}n |dkrd|jd|�}n
|jd�}|S|j|�|s�y|jj|�Wnt	k
r�YnXXdS)Nzcannot wait on un-acquired lockFTr)
rGr>r'r9rN�appendrFrE�remove�
ValueError)r+r;�waiterZsaved_stateZgotitrrr �waits*

zCondition.waitcCs\d}|}|�}xH|sV|dk	rD|dkr0t�|}n|t�}|dkrDP|j|�|�}qW|S)Nr)�_timerV)r+�	predicater;�endtimeZwaittime�resultrrr �wait_for7s


zCondition.wait_forr8cCsj|j�std��|j}tt||��}|s,dSx8|D]0}|j�y|j|�Wq2tk
r`Yq2Xq2WdS)Nz!cannot notify on un-acquired lock)rGr>rNrM�_islicer?rSrT)r+�nZall_waitersZwaiters_to_notifyrUrrr �notifyNs

zCondition.notifycCs|jt|j��dS)N)r^rPrN)r+rrr �
notify_alleszCondition.notify_all)N)N)N)r8)rIr2r3r,rJrCr7rFrErGrVr[r^r_Z	notifyAllrrrr r
�s
	
0

	c@s4eZdZddd�Zd
dd�ZeZdd	�Zd
d�ZdS)rr8cCs&|dkrtd��tt��|_||_dS)Nrz$semaphore initial value must be >= 0)rTr
r�_cond�_value)r+�valuerrr r,}szSemaphore.__init__TNc
Cs�|r|dk	rtd��d}d}|j�jxb|jdkrv|s8P|dk	rh|dkrTt�|}n|t�}|dkrhP|jj|�q(W|jd8_d}WdQRX|S)Nz.can't specify timeout for non-blocking acquireFrr8T)rTr`rarWrV)r+r:r;r=rYrrr r9�s$
zSemaphore.acquirec
Cs.|j�|jd7_|jj�WdQRXdS)Nr8)r`rar^)r+rrr r?�szSemaphore.releasecCs|j�dS)N)r?)r+r@rArBrrr rC�szSemaphore.__exit__)r8)TN)rIr2r3r,r9rJr?rCrrrr rqs


-c@seZdZddd�Zdd�ZdS)rr8cCstj||�||_dS)N)rr,�_initial_value)r+rbrrr r,�szBoundedSemaphore.__init__c
CsB|j�2|j|jkrtd��|jd7_|jj�WdQRXdS)Nz!Semaphore released too many timesr8)r`rarcrTr^)r+rrr r?�s

zBoundedSemaphore.releaseN)r8)rIr2r3r,r?rrrr r�s
c@sBeZdZdd�Zdd�Zdd�ZeZdd�Zd	d
�Zddd
�Z	dS)rcCstt��|_d|_dS)NF)r
rr`�_flag)r+rrr r,�szEvent.__init__cCs|jjt��dS)N)r`r,r)r+rrr �_reset_internal_locks�szEvent._reset_internal_lockscCs|jS)N)rd)r+rrr �is_set�szEvent.is_setc	Cs&|j�d|_|jj�WdQRXdS)NT)r`rdr_)r+rrr �setsz	Event.setc	Cs|j�d|_WdQRXdS)NF)r`rd)r+rrr �clearszEvent.clearNc	Cs,|j�|j}|s|jj|�}|SQRXdS)N)r`rdrV)r+r;Zsignaledrrr rVs
z
Event.wait)N)
rIr2r3r,rerfZisSetrgrhrVrrrr r�s
c@s|eZdZddd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zedd��Z
edd��Zedd��ZdS)rNcCs.tt��|_||_||_||_d|_d|_dS)Nr)r
rr`�_action�_timeout�_parties�_stater*)r+�parties�actionr;rrr r,?s	zBarrier.__init__cCs�|dkr|j}|j�b|j�|j}|jd7_z&|d|jkrL|j�n
|j|�|S|jd8_|j�XWdQRXdS)Nr8)rjr`�_enterr*rk�_release�_wait�_exit)r+r;�indexrrr rVOs	

zBarrier.waitcCs,x|jdkr|jj�qW|jdkr(t�dS)Nr8rrH)rHr8)rlr`rVr)r+rrr roms

zBarrier._enterc	Cs>y"|jr|j�d|_|jj�Wn|j��YnXdS)Nr8)rirlr`r_�_break)r+rrr rpxszBarrier._releasecs4�jj�fdd�|�s"�j�t��jdkr0t�dS)Ncs
�jdkS)Nr)rlr)r+rr �<lambda>�szBarrier._wait.<locals>.<lambda>r)r`r[rtrrl)r+r;r)r+r rq�s
z
Barrier._waitcCs(|jdkr$|jdkr$d|_|jj�dS)Nrr8rH)rHr8)r*rlr`r_)r+rrr rr�s

z
Barrier._exitc	CsT|j�D|jdkr6|jdkr$d|_q<|jdkr<d|_nd|_|jj�WdQRXdS)Nrr8�rH���rH)r`r*rlr_)r+rrr �reset�s


z
Barrier.resetc	Cs|j�|j�WdQRXdS)N)r`rt)r+rrr �abort�sz
Barrier.abortcCsd|_|jj�dS)Nrvrw)rlr`r_)r+rrr rt�szBarrier._breakcCs|jS)N)rk)r+rrr rm�szBarrier.partiescCs|jdkr|jSdS)Nr)rlr*)r+rrr �	n_waiting�s
zBarrier.n_waitingcCs
|jdkS)Nrvrw)rl)r+rrr �broken�szBarrier.broken)NN)N)rIr2r3r,rVrorprqrrrxryrt�propertyrmrzr{rrrr r6s	


	c@seZdZdS)rN)rIr2r3rrrr r�s�	Thread-%dcCs
|t�S)N)�_counter)�templaterrr �_newname�sr�c@seZdZdZejZdddfdfdd�dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd2dd�Zd4dd�Zed d!��Zejd"d!��Zed#d$��Zd%d&�ZeZed'd(��Zejd)d(��Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)5rFN)�daemoncCs~|dkri}||_t|pt��|_||_||_|dk	r>||_n
t�j|_d|_	d|_
t�|_d|_
d|_tj|_tj|�dS)NFT)�_target�strr��_name�_args�_kwargs�	_daemonicrr��_ident�_tstate_lockr�_started�_is_stopped�_initialized�_sys�stderr�_stderr�	_dangling�add)r+�group�targetr/r$r%r�rrr r,�s 
zThread.__init__cCs(|jj�|r|j�nd|_d|_dS)NT)r�re�_set_tstate_lockr�r�)r+�is_aliverrr re"s


zThread._reset_internal_lockscCs^d}|jj�rd}|j�|jr$d}|jr2|d7}|jdk	rJ|d|j7}d|jj|j|fS)N�initialZstartedZstoppedz daemonz %sz<%s(%s, %s)>)	r�rfr�r�r�r�r1rIr�)r+�statusrrr r7.s

zThread.__repr__cCs�|jstd��|jj�r td��t�|t|<WdQRXyt|jf�Wn,tk
rtt�t|=WdQRX�YnX|jj	�dS)Nzthread.__init__() not calledz threads can only be started once)
r�r>r�rf�_active_limbo_lock�_limbo�_start_new_thread�
_bootstrap�	ExceptionrV)r+rrr �start<s

zThread.startc
Cs.z|jr|j|j|j�Wd|`|`|`XdS)N)r�r�r�)r+rrr �runUs	z
Thread.runc	Cs2y|j�Wn |jr&tdkr&dS�YnXdS)N)�_bootstrap_innerr�r�)r+rrr r�fs
zThread._bootstrapcCst�|_dS)N)rr�)r+rrr �
_set_identzszThread._set_identcCst�|_|jj�dS)N)�
_set_sentinelr�r9)r+rrr r�}szThread._set_tstate_lockc2Cs��zT|j�|j�|jj�t�|t|j<t|=WdQRXtrLt	j
t�trZt	jt�z�y|j
�Wn�tk
r|Yn�t	r�t	jdk	r�td|jt�ft	jd�n�|jdk	�rH|j�\}}}zxtd|jd|jd�td|jd�x6|�r$td|jjj|j|jjjf|jd�|j}q�Wtd||f|jd�Wd~~~XYnXWdXWdt� ytt�=WnYnXWdQRXXdS)NzException in thread %s:
%s)�filezException in thread z2 (most likely raised during interpreter shutdown):z"Traceback (most recent call last):z  File "%s", line %s, in %sz%s: %s)r�r�r�rgr�r.r�r�r!r�rrrr��
SystemExitr��printr/�_format_excr��	_exc_info�tb_frame�f_code�co_filename�	tb_lineno�co_name�tb_nextr)r+�exc_type�	exc_valueZexc_tbrrr r��sT




zThread._bootstrap_innercCs|j}|dk	rd|_d|_dS)NT)r�r�)r+rOrrr �_stop�szThread._stopcCsByt�tt�=WdQRXWn tk
r<dtjkr8�YnXdS)NZdummy_threading)r�r.rr0r��modules)r+rrr �_delete�s
zThread._deletecCsZ|jstd��|jj�s td��|t�kr2td��|dkrD|j�n|jt|d�d�dS)NzThread.__init__() not calledz'cannot join thread before it is startedzcannot join current threadr)r;)r�r>r�rfr�_wait_for_tstate_lock�max)r+r;rrr �joins


zThread.joinTr8cCs0|j}|dkrn|j||�r,|j�|j�dS)N)r�r9r?r�)r+�blockr;rOrrr r�&szThread._wait_for_tstate_lockcCs|jS)N)r�)r+rrr r/4s	zThread.namecCst|�|_dS)N)r�r�)r+r/rrr r/?scCs|jS)N)r�)r+rrr �identDs
zThread.identcCs(|js|jj�rdS|jd�|jS)NF)r�r�rfr�)r+rrr r�Ps	
zThread.is_alivecCs|jS)N)r�)r+rrr r�`sz
Thread.daemoncCs*|jstd��|jj�r td��||_dS)NzThread.__init__() not calledz)cannot set daemon status of active thread)r�r>r�rfr�)r+�daemonicrrr r�ps

cCs|jS)N)r�)r+rrr �isDaemonxszThread.isDaemoncCs
||_dS)N)r�)r+r�rrr �	setDaemon{szThread.setDaemoncCs|jS)N)r/)r+rrr �getName~szThread.getNamecCs
||_dS)N)r/)r+r/rrr �setName�szThread.setName)NrH)TrH)rIr2r3r�r��exc_infor�r,rer7r�r�r�r�r�r�r�r�r�r�r|r/�setterr�r�ZisAliver�r�r�r�r�rrrr r�s6	,A#
&
c@s&eZdZddd�Zdd�Zdd�ZdS)	rNcCsFtj|�||_||_|dk	r"|ng|_|dk	r4|ni|_t�|_dS)N)rr,�interval�functionr$r%r�finished)r+r�r�r$r%rrr r,�s
zTimer.__init__cCs|jj�dS)N)r�rg)r+rrr �cancel�szTimer.cancelcCs6|jj|j�|jj�s(|j|j|j�|jj�dS)N)r�rVr�rfr�r$r%rg)r+rrr r��s
z	Timer.run)NN)rIr2r3r,r�r�rrrr r�s	
c@seZdZdd�ZdS)�_MainThreadc
CsHtj|ddd�|j�|jj�|j�t�|t|j<WdQRXdS)NZ
MainThreadF)r/r�)	rr,r�r�rgr�r�r.r�)r+rrr r,�s
z_MainThread.__init__N)rIr2r3r,rrrr r��sr�c@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)�_DummyThreadc
CsDtj|td�dd�|jj�|j�t�|t|j<WdQRXdS)NzDummy-%dT)r/r�)	rr,r�r�rgr�r�r.r�)r+rrr r,�s

z_DummyThread.__init__cCsdS)Nr)r+rrr r��sz_DummyThread._stopcCsdS)NTr)r+rrr r��sz_DummyThread.is_aliveNcCsdS)Nr)r+r;rrr r��sz_DummyThread.join)N)rIr2r3r,r�r�r�rrrr r��sr�cCs&y
tt�Stk
r t�SXdS)N)r.rr0r�rrrr r�s
c
Cs t�tt�tt�SQRXdS)N)r�rPr.r�rrrr r	�scCsttj��ttj��S)N)�listr.�valuesr�rrrr �
_enumerate�sr�c
Cs(t�ttj��ttj��SQRXdS)N)r�r�r.r�r�rrrr r�s)rcCs8tj}|j�tj�t�}x|r2|j�t�}qWdS)N)�_main_threadr�r?r��_pickSomeNonDaemonThreadr�)Ztlockr@rrr �	_shutdown�sr�cCs(x"t�D]}|jr|j�r|SqWdS)N)rr�r�)r@rrr r�sr�cCstS)N)r�rrrr r
s)�_local)rcCs�t�ai}t�}|at�|tt��}|jt�xF|D]>}||kr`|jd�t	�}||_
|||<q4|jd�|j�q4Wtj
�tj
�tj|�WdQRXdS)NTF)r'r�rr�rgr��updater�rerr�r�r�rhr.)Z
new_activeZcurrentZthreadsZthreadr�rrr �_after_fork(s&






r�)r})J�sysr��_threadZtimerrW�	tracebackrr��_weakrefsetr�	itertoolsrr\rr*�_collectionsrrM�ImportError�collections�__all__�start_new_threadr��
allocate_lockr'r�r�errorrrr"rLrrr!rrrr&r#r
rrrrr>r�__next__r~r�r�r.r�r�rrr�r�rZ
currentThreadr	ZactiveCountr�rrr�r�r�r
r�rZ_threading_localr�rrrr �<module>s�



q'P&O
'


?>