Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_queue.cpython-310.pyc
o

�9jR�@sddlZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ej
ddgd�Zej
ddgd�Ze�
ed	�Zd
Zdd�ZGd
d�dej�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�deej�ZeGdd�deej��ZGdd�de�ZGdd�deej�ZeGdd�deej��ZGdd �d e�ZGd!d"�d"eej�ZeGd#d$�d$eej��ZGd%d&�d&e�Z Gd'd(�d(e�Z!Gd)d*�d*e!ej�Z"eGd+d,�d,e!ej��Z#Gd-d.�d.�Z$Gd/d0�d0e$ej�Z%eGd1d2�d2e$ej��Z&e'd3k�re�(�dSdS)4�N)�
gc_collect)�
import_helper)�threading_helper�queue�_queue)�blocked)�freshzNo _queue module found�cCs|jdko|��|jkS�Nr)�maxsize�qsize)�q�r�&/usr/lib/python3.10/test/test_queue.py�qfullsrc@�eZdZdd�Zdd�ZdS)�_TriggerThreadcCs&||_||_t��|_tj�|�dS�N)�fn�args�	threading�Event�startedEvent�Thread�__init__)�selfrrrrrrs
z_TriggerThread.__init__cCs$t�d�|j��|j|j�dS)N皙�����?)�time�sleepr�setrr�rrrr�runs
	
z_TriggerThread.runN)�__name__�
__module__�__qualname__rr!rrrrrsrc@r)�BlockingTestMixinc	CsTt||�}|��z||�|_|j��s|�d|�|jWt�|�St�|�w)Nz*blocking function %r appeared not to block)r�start�resultr�is_set�failr�join_thread)r�
block_func�
block_args�trigger_func�trigger_args�threadrrr�do_blocking_test:s


�z"BlockingTestMixin.do_blocking_testc	Cs�t||�}|��z*z||�Wn|y�w|�d|�Wt�|�|j��s2|�d�dSdSt�|�|j��sD|�d�ww)Nzexpected exception of kind %rz(trigger thread ended but event never set)rr&r)rr*rr()rr+r,r-r.�expected_exception_classr/rrr�do_exceptional_blocking_testHs&
��

�
�
�z.BlockingTestMixin.do_exceptional_blocking_testN)r"r#r$r0r2rrrrr%8sr%c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BaseQueueTestMixincCsd|_t��|_dSr
)�cumr�Lock�cumlockr rrr�setUp[szBaseQueueTestMixin.setUpcCsh|��rtd��|�|���|�|���|�d�|�d�|�d�tgd�gd�gd�d�}|��|��|��g}|�	|||j
jd	�tt
d
�D]}|�|�|�|��d�qN|�t|�d�d
t
}dt
}|�|�|�t|�d�|�|���|�|���z|j|dd�|�d�Wn|jjy�Ynwz|j|dd�|�d�Wn|jjy�Ynw|�|j|f|jd�|�|j|ddf|jd�tt
�D]}|��q�|�|��d�z
|jdd�|�d�Wn|jj�yYnwz
|jdd�|�d�Wn|jj�yYnw|�|jd|jd�|�|jd|jd�dS)N�&Call this function with an empty queue�o�M��)r9r:r;)r;r:r9)r9r;r:)�Queue�	LifoQueue�
PriorityQueuez&Didn't seem to queue the correct data!��Queue should not be empty�Queue should not be full���Queue should be fullr��blockz(Didn't appear to block with a full queueg{�G�z�?��timeoutz+Didn't appear to time-out with a full queuerT�
�Queue should be emptyz*Didn't appear to block with an empty queuez-Didn't appear to time-out with an empty queue��empty)TrI)r�RuntimeError�
assertTruerL�assertFalse�full�put�dict�get�assertEqual�	__class__r"�range�
QUEUE_SIZErr)r�Fullr0�Empty)rr
�target_order�actual_order�i�lastrPrrr�basic_queue_test_sp


��

��
��z#BaseQueueTestMixin.basic_queue_testcCs\	|��}|dkr|��dS|j�|j|7_Wd�n1s$wY|��q)NTr)rS�	task_doner6r4)rr
�xrrr�worker�s��zBaseQueueTestMixin.workercCs�d|_g}dD]}tj|j|fd�}|��|�|�qtd�D]}|�|�q |��|�	|jt
td��d�dD]}|�d�q:|��|D]}|��qHdS)Nr)rr?��targetr�dz0q.join() did not block until all tasks were done���)r4rrrar&�appendrVrQ�joinrT�sum)rr
�threadsr\r/rrr�queue_join_test�s$�
�z"BaseQueueTestMixin.queue_join_testcCs8|��}z|��Wn
tyYdSw|�d�dS�Nz(Did not detect task count going negative)�	type2testr_�
ValueErrorr)�rr
rrr�test_queue_task_done�s�z'BaseQueueTestMixin.test_queue_task_donecCsL|��}|�|�|�|�z|��Wn
tyYdSw|�d�dSrk)rlrjr_rmr)rnrrr�test_queue_join�s

�z"BaseQueueTestMixin.test_queue_joincC�"|�t�}|�|�|�|�dSr)rlrWr^rnrrr�
test_basic�s

zBaseQueueTestMixin.test_basiccCs�|�t�}|�t��|jddd�Wd�n1swY|�t��|jddd�Wd�dS1s9wYdS�Nr?rerG)rlrW�assertRaisesrmrQrSrnrrr�&test_negative_timeout_raises_exception�s
�"�z9BaseQueueTestMixin.test_negative_timeout_raises_exceptioncCs�|�t�}tt�D]}|�d�q	|�|jj��
|�d�Wd�n1s(wYtt�D]}|��q1|�|jj��
|��Wd�dS1sOwYdS)Nr?)	rlrWrV�
put_nowaitrtrrX�
get_nowaitrY�rr
r\rrr�test_nowait�s
�

"�zBaseQueueTestMixin.test_nowaitcCs�|�d�}|�d�|�d�|�d�|�|jj��
|�d�Wd�n1s+wY|�|��d�d|_|�|jj��|�d�Wd�dS1sSwYdS)N�r?rB�)	rlrQrtrrXrvrTrrrnrrr�test_shrinking_queue�s



�"�z'BaseQueueTestMixin.test_shrinking_queueN)
r"r#r$r7r^rarjrorprrruryr|rrrrr3Zs9


r3c�eZdZ�fdd�Z�ZS)�	QueueTestc�|jj|_t���dSr)rr<rl�superr7r �rUrrr7��
zQueueTest.setUp�r"r#r$r7�
__classcell__rrr�rr~��r~c@�eZdZeZdS)�PyQueueTestN�r"r#r$�py_queuerrrrrr���r�c@r�)�
CQueueTestN�r"r#r$�c_queuerrrrrr���r�cr})�
LifoQueueTestcrr)rr=rlr�r7r r�rrr7r�zLifoQueueTest.setUpr�rrr�rr�r�r�c@r�)�PyLifoQueueTestNr�rrrrr�r�r�c@r�)�CLifoQueueTestNr�rrrrr�r�r�cr})�PriorityQueueTestcrr)rr>rlr�r7r r�rrr7r�zPriorityQueueTest.setUpr�rrr�rr�r�r�c@r�)�PyPriorityQueueTestNr�rrrrr�r�r�c@r�)�CPriorityQueueTestNr�rrrrr�r�r�c@�eZdZdS)�FailingQueueExceptionN�r"r#r$rrrrr�"sr�cs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�FailingQueueTestcs0|jj�G�fdd�d��}||_t���dS)Ncs0eZdZ�fdd�Z�fdd�Z�fdd�ZdS)z,FailingQueueTest.setUp.<locals>.FailingQueuecs"d|_d|_�j|g|�R�dS)NF)�
fail_next_put�
fail_next_getr)rr�r<rrr+sz5FailingQueueTest.setUp.<locals>.FailingQueue.__init__cs |jr
d|_td����||�S�NFzYou Lose)r�r��_put)r�itemr�rrr�/sz1FailingQueueTest.setUp.<locals>.FailingQueue._putcs|jr
d|_td����|�Sr�)r�r��_getr r�rrr�4s
z1FailingQueueTest.setUp.<locals>.FailingQueue._getN)r"r#r$rr�r�rr�rr�FailingQueue*sr�)rr<r�r�r7)rr�r�r�rr7&szFailingQueueTest.setUpcCs�|��rtd��ttd�D]}|�|�qd|_z|jddd�|�d�Wn	ty0Ynwd|_z|jddd	�|�d�Wn	tyKYnw|�d
�|�t	|�d�d|_z|�
|jd|jd
�|�d�Wn	tyvYnw|�d
�d|_z|�|jd|jd
t�|�d�Wn	ty�Ynw|�d
�|�t	|�d�|��|�t	|�d�|�d
�|�t	|�d�|�
|jd|jd
�tt�D]}|��q�|�|��d�|�d�d|_
z|��|�d�Wn	ty�Ynw|�|��d�d|_
z
|jdd	�|�d�Wn
t�yYnw|�|��d�|��|�|��d�d|_
z|�|jd
|jdt�|�d�Wn
t�yTYnw|�|��d�|��|�|��d�dS)Nr8r?T�oopsrrEz)The queue didn't fail when it should haverrGr]rD)rPr)rPTrIrArJ�firstr@rK)rrMrVrWrQr�r)r�rNrr0rSr2r�rxrrr�failing_queue_test>s���
�
��



����z#FailingQueueTest.failing_queue_testcCrqr)r�rWr�rnrrr�test_failing_queue�s

z#FailingQueueTest.test_failing_queue)r"r#r$r7r�r�r�rrr�rr�$sQr�c@r�)�PyFailingQueueTestNr�rrrrr��r�r�c@r�)�CFailingQueueTestNr�rrrrr��r�r�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�BaseSimpleQueueTestcCs|��|_dSr)rlr
r rrrr7�szBaseSimpleQueueTest.setUpcCsX	z|��}Wnty|�|�YdSw|�|�|��dkr+t�|��d�q)NTg�?���MbP?)�pop�
IndexErrorrQ�randomrr)rr
�seq�rnd�sentinel�valrrr�feed�s
�
�zBaseSimpleQueueTest.feedcCs"	|��}||krdS|�|�qr)rSrf�rr
�resultsr�r�rrr�consume�s
�zBaseSimpleQueueTest.consumecCsR		z|jdd�}Wn|jjyt�d�Ynwnq||kr#dS|�|�q)NTFrE��h㈵��>)rSrrYrrrfr�rrr�consume_nonblock�s��
�z$BaseSimpleQueueTest.consume_nonblockcCsH		z|jdd�}Wn|jjyYnwnq||krdS|�|�q)NTr�rG)rSrrYrfr�rrr�consume_timeout�s��
�z#BaseSimpleQueueTest.consume_timeoutcs�g�d�|������t�d��g��fdd��������fdd�t|�D�}�����fdd�t|�D�}t�||��Wd�n1sJwY|���|���	��|�
���d��S)N�*cs��fdd�}|S)Nc
sFz
�|i|��WdSty"}z��|�WYd}~dSd}~wwr)�
BaseExceptionrf)r�kwargs�e)�
exceptions�frr�wrapper�s��zHBaseSimpleQueueTest.run_threads.<locals>.log_exceptions.<locals>.wrapperr)r�r�)r�)r�r�log_exceptions�sz7BaseSimpleQueueTest.run_threads.<locals>.log_exceptionscs&g|]}tj�������fd��qS�rb�rr��.0r\)�	feed_funcr�r
r�r�r�rr�
<listcomp>�s

�

�z3BaseSimpleQueueTest.run_threads.<locals>.<listcomp>cs$g|]}tj������fd��qSr�r�r�)�consume_funcr�r
r�r�rrr��s

�
�r)�copy�reverser��RandomrVr�
start_threadsrOrNrLrTr)r�	n_threadsr
�inputsr�r��feeders�	consumersr)	r�r�r�r�r
r�r�r�r�r�run_threads�s(
���
zBaseSimpleQueueTest.run_threadscCs�|j}|�|���|�|��d�|�d�|�|���|�|��d�|�d�|�d�|�d�|�|���|�|��d�|�|��d�|�|��d�|�|�	�d�|�|��d�|�|jdd�d�|�|���|�|��d�|�|jdd	�d�|�|���|�|��d�|�
|jj��|jdd�Wd�n1s�wY|�
|jj��|jd
d	�Wd�n1s�wY|�
|jj��|�	�Wd�n1s�wY|�|���|�|��d�dS)Nrr?rBrzr{FrErrGr�)
r
rNrLrTrrQrOrvrSrwrtrrYrnrrrrr�s@



��
�zBaseSimpleQueueTest.test_basiccCsL|j}|�d�|�t��|jdd�Wd�dS1swYdSrs)r
rQrtrmrSrnrrrrus

"�z:BaseSimpleQueueTest.test_negative_timeout_raises_exceptioncCs8|j}ttd��}|�d|||j|j�}|�||�dS)Nrdr?)r
�listrVr�r�r�rT)rr
r�r�rrr�
test_orderszBaseSimpleQueueTest.test_ordercC�@d}|j}ttd��}|�||||j|j�}|�t|�|�dS�N�2�')r
r�rVr�r�r�rT�sorted�r�Nr
r�r�rrr�test_many_threads's
z%BaseSimpleQueueTest.test_many_threadscCr�r�)r
r�rVr�r�r�rTr�r�rrr�test_many_threads_nonblock2�
�z.BaseSimpleQueueTest.test_many_threads_nonblockcCr�)Nr�i�)r
r�rVr�r�r�rTr�r�rrr�test_many_threads_timeout<r�z-BaseSimpleQueueTest.test_many_threads_timeoutcCsdGdd�d�}d}|j}t|�D]}|�|��qt|�D]}t�|���}t�|�|��qdS)Nc@r�)z.BaseSimpleQueueTest.test_references.<locals>.CNr�rrrr�CIsr��)r
rVrQ�weakref�refrSr�assertIsNone)rr�r�r
r\�wrrrr�test_referencesFs�z#BaseSimpleQueueTest.test_referencesN)r"r#r$r7r�r�r�r�r�rrrur�r�r�r�r�rrrrr��s

 %	

r�cs eZdZeZ�fdd�Z�ZS)�PySimpleQueueTestcrr)r�_PySimpleQueuerlr�r7r r�rrr7Yr�zPySimpleQueueTest.setUp)r"r#r$r�rr7r�rrr�rr�Vsr�cs0eZdZeZ�fdd�Zdd�Zdd�Z�ZS)�CSimpleQueueTestcrr)r�SimpleQueuerlr�r7r r�rrr7cr�zCSimpleQueueTest.setUpcCs(|�|j|jj�|�|j|jj�dSr)�assertIsrlrr�r rrr�test_is_defaultgsz CSimpleQueueTest.test_is_defaultcs~|j�t���d}g}G��fdd�dt�}	|�}��t���~|�����|d|kr0nq|�|t	t
|d���dS)Nr�cs"eZdZdd�Z��fdd�ZdS)z2CSimpleQueueTest.test_reentrancy.<locals>.CircularcSs
||_dSr)�circularr rrrrws
z;CSimpleQueueTest.test_reentrancy.<locals>.Circular.__init__cs��t���dSr)rQ�nextr ��genr
rr�__del__zsz:CSimpleQueueTest.test_reentrancy.<locals>.Circular.__del__N)r"r#r$rr�rr�rr�Circularvsr�Trer?)r
�	itertools�count�objectrQr�rfrSrTr�rV)rr�r�r��orr�r�test_reentrancyks�z CSimpleQueueTest.test_reentrancy)	r"r#r$r�rr7r�r�r�rrr�rr�^s
r��__main__))r�r�rr�unittestr��test.supportrrr�import_fresh_moduler�r��
skipUnless�need_c_queuerWrrrr%r3r~�TestCaser�r�r�r�r�r�r�r��	Exceptionr�r�r�r�r�r�r�r"�mainrrrr�<module>sV "u5
)�

Youez - 2016 - github.com/yon3zu
LinuXploit