ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/threading.cpython-35.opt-2.pyc



���]���@sOddlZddlZddlmZddlmZddl	m
Z
ddlmZ
mZyddlmZWn"ek
r�ddlmZYnXddd	d
ddd
ddddddddddgZejZejZejZejZejZy
ejZWne k
r$dZYnXej!Z![da"da#dd�Z$dd�Z%eZ&dd
�ZGdd�d�Z'e'Z(Gdd�d�Z)Gdd�d�Z*Gdd�de*�Z+Gd d�d�Z,Gd!d�d�Z-Gd"d#�d#e.�Z/e�j0Z1e1�d$d%d&�Z2e�a3iZ4iZ5e
�Z6Gd'd�d�Z7Gd(d�de7�Z8Gd)d*�d*e7�Z9Gd+d,�d,e7�Z:d-d	�Z;e;Z<d.d�Z=e=Z>d/d0�Z?d1d
�Z@dd2lmAZAe9�aBd3d4�ZCd5d6�ZDd7d8�ZEydd9lmFZGWn"ek
r>dd:lHmGZGYnXd;d<�ZIdS)=�N)�	monotonic)�
format_exc)�WeakSet)�islice�count)�deque�active_count�	Condition�current_thread�	enumerate�Event�Lock�RLock�	Semaphore�BoundedSemaphore�Thread�Barrier�Timer�ThreadError�
setprofile�settrace�local�
stack_sizecCs
|adS)N)�
_profile_hook)�func�r�./opt/alt/python35/lib64/python3.5/threading.pyr0scCs
|adS)N)�_trace_hook)rrrrr:scOs&tdkrt||�St||�S)N)�_CRLock�_PyRLock)�args�kwargsrrrrHs	
c@s|eZdZdd�Zdd�Zdddd�ZeZd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_RLockcCs"t�|_d|_d|_dS)Nr)�_allocate_lock�_block�_owner�_count)�selfrrr�__init___s	z_RLock.__init__cCsy|j}yt|j}Wntk
r.YnXd|jj�rGdnd|jj|jj||j	t
t|��fS)Nz)<%s %s.%s object owner=%r count=%d at %s>�locked�unlocked)r%�_active�name�KeyErrorr$r)�	__class__�
__module__�__qualname__r&�hex�id)r'�ownerrrr�__repr__ds	
		z_RLock.__repr__T�cCs\t�}|j|kr+|jd7_dS|jj||�}|rX||_d|_|S)Nr5)�	get_identr%r&r$�acquire)r'�blocking�timeout�me�rcrrrr7ss			z_RLock.acquirecCsR|jt�krtd��|jd|_}|sNd|_|jj�dS)Nzcannot release un-acquired lockr5)r%r6�RuntimeErrorr&r$�release)r'rrrrr=�s	z_RLock.releasecCs|j�dS)N)r=)r'�t�v�tbrrr�__exit__�sz_RLock.__exit__cCs#|jj�|\|_|_dS)N)r$r7r&r%)r'�staterrr�_acquire_restore�s
z_RLock._acquire_restorecCsV|jdkrtd��|j}d|_|j}d|_|jj�||fS)Nrzcannot release un-acquired lock)r&r<r%r$r=)r'rr3rrr�
_release_save�s				
z_RLock._release_savecCs|jt�kS)N)r%r6)r'rrr�	_is_owned�sz_RLock._is_ownedN���)�__name__r/r0r(r4r7�	__enter__r=rArCrDrErrrrr"Us
$
r"c@s�eZdZddd�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
rZYnXy|j|_Wntk
rYnXy|j|_Wntk
r�YnXt�|_	dS)N)
r�_lockr7r=rD�AttributeErrorrCrE�_deque�_waiters)r'�lockrrrr(�s$		


zCondition.__init__cCs
|jj�S)N)rIrH)r'rrrrH�szCondition.__enter__cGs|jj|�S)N)rIrA)r'r rrrrA�szCondition.__exit__cCsd|jt|j�fS)Nz<Condition(%s, %d)>)rI�lenrL)r'rrrr4�szCondition.__repr__cCs|jj�dS)N)rIr=)r'rrrrD�szCondition._release_savecCs|jj�dS)N)rIr7)r'�xrrrrC�szCondition._acquire_restorecCs+|jjd�r#|jj�dSdSdS)NrFT)rIr7r=)r'rrrrE�s
zCondition._is_ownedcCs�|j�std��t�}|j�|jj|�|j�}d}zW|dkro|j�d}n0|dkr�|jd|�}n|jd�}|SWd|j|�|s�y|jj|�Wnt	k
r�YnXXdS)Nzcannot wait on un-acquired lockFTr)
rEr<r#r7rL�appendrDrC�remove�
ValueError)r'r9�waiter�saved_state�gotitrrr�waits*	

	

zCondition.waitcCs~d}|}|�}xb|sy|dk	r`|dkrFt�|}n|t�}|dkr`P|j|�|�}qW|S)Nr)�_timerV)r'�	predicater9�endtime�waittime�resultrrr�wait_for5s		


zCondition.wait_forr5cCs�|j�std��|j}tt||��}|s@dSx>|D]6}|j�y|j|�WqGtk
r|YqGXqGWdS)Nz!cannot notify on un-acquired lock)rEr<rLrK�_islicer=rQrR)r'�n�all_waiters�waiters_to_notifyrSrrr�notifyLs
	


zCondition.notifycCs|jt|j��dS)N)rarNrL)r'rrr�
notify_allcszCondition.notify_all)rGr/r0r(rHrAr4rDrCrErVr\rarb�	notifyAllrrrrr	�s	0	c@sOeZdZddd�Zdddd�ZeZdd	�Zd
d�ZdS)rr5cCs7|dkrtd��tt��|_||_dS)Nrz$semaphore initial value must be >= 0)rRr	r
�_cond�_value)r'�valuerrrr({szSemaphore.__init__TNc
Cs�|r|dk	rtd��d}d}|j��x�|jdkr�|sNP|dk	r�|dkrvt�|}n|t�}|dkr�P|jj|�q8W|jd8_d}WdQRX|S)Nz.can't specify timeout for non-blocking acquireFrr5T)rRrdrerWrV)r'r8r9r;rYrrrr7�s$


zSemaphore.acquirec
Cs1|j�!|jd7_|jj�WdQRXdS)Nr5)rdrera)r'rrrr=�s
zSemaphore.releasecCs|j�dS)N)r=)r'r>r?r@rrrrA�szSemaphore.__exit__)rGr/r0r(r7rHr=rArrrrros
-c@s+eZdZddd�Zdd�ZdS)rr5cCstj||�||_dS)N)rr(�_initial_value)r'rfrrrr(�szBoundedSemaphore.__init__c
CsO|j�?|j|jkr(td��|jd7_|jj�WdQRXdS)Nz!Semaphore released too many timesr5)rdrergrRra)r'rrrr=�s


zBoundedSemaphore.releaseN)rGr/r0r(r=rrrrr�sc@saeZdZdd�Zdd�Zdd�ZeZdd�Zd	d
�Zddd
�Z	dS)rcCstt��|_d|_dS)NF)r	r
rd�_flag)r'rrrr(�szEvent.__init__cCs|jjt��dS)N)rdr(r
)r'rrr�_reset_internal_locks�szEvent._reset_internal_lockscCs|jS)N)rh)r'rrr�is_set�szEvent.is_setc	Cs+|j�d|_|jj�WdQRXdS)NT)rdrhrb)r'rrr�set�s
	z	Event.setc	Cs|j�d|_WdQRXdS)NF)rdrh)r'rrr�clear	s
zEvent.clearNc	Cs:|j�*|j}|s+|jj|�}|SWdQRXdS)N)rdrhrV)r'r9�signaledrrrrVs

	z
Event.wait)
rGr/r0r(rirj�isSetrkrlrVrrrrr�s
c@s�eZdZdddd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zedd��Z
edd��Zedd��ZdS)rNcCsCtt��|_||_||_||_d|_d|_dS)Nr)r	r
rd�_action�_timeout�_parties�_stater&)r'�parties�actionr9rrrr(=s					zBarrier.__init__cCs�|dkr|j}|j�y|j�|j}|jd7_z5|d|jkrd|j�n
|j|�|SWd|jd8_|j�XWdQRXdS)Nr5)rprd�_enterr&rq�_release�_wait�_exit)r'r9�indexrrrrVMs		

	

zBarrier.waitcCs<x |jdkr"|jj�qW|jdkr8t�dS)Nr5rrF)rFr5)rrrdrV�BrokenBarrierError)r'rrrruks
zBarrier._enterc	CsIy-|jr|j�d|_|jj�Wn|j��YnXdS)Nr5)rorrrdrb�_break)r'rrrrvvs	
	
zBarrier._releasecsJ�jj�fdd�|�s1�j�t��jdkrFt�dS)Ncs
�jdkS)Nr)rrr)r'rr�<lambda>�szBarrier._wait.<locals>.<lambda>r)rdr\r{rzrr)r'r9r)r'rrw�s!
z
Barrier._waitcCs8|jdkr4|jdkr4d|_|jj�dS)Nrr5rF)rFr5)r&rrrdrb)r'rrrrx�s	z
Barrier._exitc	Csp|j�`|jdkrO|jdkr4d|_qX|jdkrXd|_n	d|_|jj�WdQRXdS)Nrr5�rF���rF)rdr&rrrb)r'rrr�reset�s
	z
Barrier.resetc	Cs|j�|j�WdQRXdS)N)rdr{)r'rrr�abort�s
z
Barrier.abortcCsd|_|jj�dS)Nr}r~)rrrdrb)r'rrrr{�s	zBarrier._breakcCs|jS)N)rq)r'rrrrs�szBarrier.partiescCs|jdkr|jSdS)Nr)rrr&)r'rrr�	n_waiting�szBarrier.n_waitingcCs
|jdkS)Nr}r~)rr)r'rrr�broken�szBarrier.broken)rGr/r0r(rVrurvrwrxrr�r{�propertyrsr�r�rrrrr4s	
	c@seZdZdS)rzN)rGr/r0rrrrrz�srzz	Thread-%dcCs|t�S)N)�_counter)�templaterrr�_newname�sr�c	@s{eZdZdZejZdddfddddd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zddd�Zdd2dd�Zed d!��Zejd"d!��Zed#d$��Zd%d&�ZeZed'd(��Zejd)d(��Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)3rFN�daemoncCs�|dkri}||_t|p*t��|_||_||_|dk	r]||_nt�j|_d|_	d|_
t�|_d|_
d|_tj|_tj|�dS)NFT)�_target�strr��_name�_args�_kwargs�	_daemonicr
r��_ident�_tstate_lockr�_started�_is_stopped�_initialized�_sys�stderr�_stderr�	_dangling�add)r'�group�targetr,r r!r�rrrr(�s 							zThread.__init__cCs6|jj�|r |j�nd|_d|_dS)NT)r�ri�_set_tstate_lockr�r�)r'�is_aliverrrri s


	zThread._reset_internal_lockscCs�d}|jj�rd}|j�|jr4d}|jrG|d7}|jdk	rg|d|j7}d|jj|j|fS)N�initial�started�stoppedz daemonz %sz<%s(%s, %s)>)	r�rjr�r�r�r�r.rGr�)r'�statusrrrr4,s
		
zThread.__repr__cCs�|jstd��|jj�r0td��t�|t|<WdQRXyt|jf�Wn*tk
r�t�t|=WdQRX�YnX|jj	�dS)Nzthread.__init__() not calledz threads can only be started once)
r�r<r�rj�_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�runSs		z
Thread.runc	Cs9y|j�Wn$|jr-tdkr-dS�YnXdS)N)�_bootstrap_innerr�r�)r'rrrr�ds
zThread._bootstrapcCst�|_dS)N)r6r�)r'rrr�
_set_identxszThread._set_identcCst�|_|jj�dS)N)�
_set_sentinelr�r7)r'rrrr�{szThread._set_tstate_lockc2Cs�z�|j�|j�|jj�t�|t|j<t|=WdQRXtrYt	j
t�trlt	jt�z7y|j
�Wn"tk
r�Ynt	r�t	jdk	r�td|jt�fdt	j�n�|jdk	r�|j�\}}}z�td|jdd|j�tdd|j�xH|rqtd|jjj|j|jjjfd|j�|j}q*Wtd||fd|j�Wd~~~XYnXWdXWdt�ytt�=WnYnXWdQRXXdS)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�rkr�r+r�r�rr�rrrr��
SystemExitr��printr,�_format_excr��	_exc_info�tb_frame�f_code�co_filename�	tb_lineno�co_name�tb_nextr6)r'�exc_type�	exc_value�exc_tbrrrr��sT






 
	
!zThread._bootstrap_innercCs+|j}|dk	rd|_d|_dS)NT)r�r�)r'rMrrr�_stop�s		zThread._stopcCsGyt�tt�=WdQRXWn$tk
rBdtjkr>�YnXdS)N�dummy_threading)r�r+r6r-r��modules)r'rrr�_delete�s
zThread._deletecCs�|jstd��|jj�s0td��|t�krKtd��|dkrd|j�n|jdt|d��dS)NzThread.__init__() not calledz'cannot join thread before it is startedzcannot join current threadr9r)r�r<r�rjr
�_wait_for_tstate_lock�max)r'r9rrr�join�s	
zThread.joinTr5cCsB|j}|dkrn&|j||�r>|j�|j�dS)N)r�r7r=r�)r'�blockr9rMrrrr�$s	
zThread._wait_for_tstate_lockcCs|jS)N)r�)r'rrrr,2s	zThread.namecCst|�|_dS)N)r�r�)r'r,rrrr,=scCs|jS)N)r�)r'rrr�identBs
zThread.identcCs2|js|jj�rdS|jd�|jS)NF)r�r�rjr�)r'rrrr�Ns	
zThread.is_alivecCs|jS)N)r�)r'rrrr�^sz
Thread.daemoncCs=|jstd��|jj�r0td��||_dS)NzThread.__init__() not calledz)cannot set daemon status of active thread)r�r<r�rjr�)r'�daemonicrrrr�ns
	cCs|jS)N)r�)r'rrr�isDaemonvszThread.isDaemoncCs
||_dS)N)r�)r'r�rrr�	setDaemonyszThread.setDaemoncCs|jS)N)r,)r'rrr�getName|szThread.getNamecCs
||_dS)N)r,)r'r,rrr�setNameszThread.setNamerF)rGr/r0r�r��exc_infor�r(rir4r�r�r�r�r�r�r�r�r�r�r�r,�setterr�r��isAliver�r�r�r�r�rrrrr�s6			,A#&c@s:eZdZdddd�Zdd�Zdd�ZdS)rNcCsetj|�||_||_|dk	r1|ng|_|dk	rL|ni|_t�|_dS)N)rr(�interval�functionr r!r�finished)r'r�r�r r!rrrr(�s
		zTimer.__init__cCs|jj�dS)N)r�rk)r'rrr�cancel�szTimer.cancelcCsI|jj|j�|jj�s8|j|j|j�|jj�dS)N)r�rVr�rjr�r r!rk)r'rrrr��sz	Timer.run)rGr/r0r(r�r�rrrrr�s	c@seZdZdd�ZdS)�_MainThreadc
CsYtj|dddd�|j�|jj�|j�t�|t|j<WdQRXdS)Nr,�
MainThreadr�F)	rr(r�r�rkr�r�r+r�)r'rrrr(�s


z_MainThread.__init__N)rGr/r0r(rrrrr��sr�c@sCeZdZdd�Zdd�Zdd�Zddd	�ZdS)
�_DummyThreadc
CsUtj|dtd�dd�|jj�|j�t�|t|j<WdQRXdS)Nr,zDummy-%dr�T)	rr(r�r�rkr�r�r+r�)r'rrrr(�s


z_DummyThread.__init__cCsdS)Nr)r'rrrr��sz_DummyThread._stopcCsdS)NTr)r'rrrr��sz_DummyThread.is_aliveNcCsdS)Nr)r'r9rrrr��sz_DummyThread.join)rGr/r0r(r�r�r�rrrrr��sr�cCs/ytt�SWntk
r*t�SYnXdS)N)r+r6r-r�rrrrr
�s
c
Cs&t�tt�tt�SWdQRXdS)N)r�rNr+r�rrrrr�scCs ttj��ttj��S)N)�listr+�valuesr�rrrr�
_enumerate�sr�c
Cs2t�%ttj��ttj��SWdQRXdS)N)r�r�r+r�r�rrrrr�s)rcCsTtj}|j�tj�t�}x|rE|j�t�}q)Wtj�dS)N)�_main_threadr�r=r��_pickSomeNonDaemonThreadr�r�)�tlockr>rrr�	_shutdown�s	

		

r�cCs2x+t�D] }|jr
|j�r
|Sq
WdS)N)rr�r�)r>rrrr�sr�cCstS)N)r�rrrr�main_threadsr�)�_local)rcCs�t�ai}t�}|at��tt��}|jt�x]|D]U}||kr�|jd�t	�}||_
|||<qH|jd�|j�qHWtj
�tj
�tj|�WdQRXdS)NTF)r#r�r
r�rkr��updater�rir6r�r�r�rlr+)�
new_active�current�threads�threadr�rrr�_after_fork's&		


		




r�)J�sysr��_thread�timerrW�	tracebackrr��_weakrefsetr�	itertoolsrr]rr&�_collectionsrrK�ImportError�collections�__all__�start_new_threadr��
allocate_lockr#r�r6�errorrrrrJ�TIMEOUT_MAXrrrrr
r"rr	rrrrr<rz�__next__r�r�r�r+r�r�rrr�r�r
�
currentThreadr�activeCountr�rrr�r�r�r�r�rZ_threading_localr�rrrr�<module>s�
					

	

q�P&O�		��
	


Zerion Mini Shell 1.0