HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_asyncio/__pycache__/test_locks.cpython-310.pyc
o

�i�u�@s�dZddlZddlmZddlZddlZddlZdZe�e�Zdd�Z	Gdd�dej
�ZGd	d
�d
ej
�ZGdd�dej
�Z
Gd
d�dej
�ZedkrQe��dSdS)zTests for lock.py�N)�mockzv^<(?P<class>.*?) object at (?P<address>.*?)\[(?P<extras>(set|unset|locked|unlocked)(, value:\d)?(, waiters:\d+)?)\]>\ZcCst�d�dS�N)�asyncioZset_event_loop_policy�rr�9/usr/local/lib/python3.10/test/test_asyncio/test_locks.py�tearDownModulesrc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�	LockTestsc�sl�t��}|�t|��d��|�t�t|���|��IdH|�t|��d��|�t�t|���dS)Nz[unlocked]>�	[locked]>)r�Lock�
assertTrue�repr�endswith�RGX_REPR�match�acquire��self�lockrrr�	test_reprs�zLockTests.test_reprc�s��t���|�t��tj�fdd��}Wd�n1swY|�td��|�IdHWd�n1s:wY|�����dS)Nc3���EdHSrrr�rrr�acquire_lock&��
z)LockTests.test_lock.<locals>.acquire_lock�object is not iterable)	rr
�assertWarns�DeprecationWarning�	coroutine�assertRaisesRegex�	TypeError�assertFalse�locked�rrrrr�	test_lock"s����zLockTests.test_lockc	�sp�tjtjtjtjtjg}t��}|D]"}|�td|j	�d���
||d�Wd�n1s0wYqdS)Nz4As of 3.10, the \*loop\* parameter was removed from z$\(\) since it is no longer necessary��loop)
rr
�	Condition�Event�	Semaphore�BoundedSemaphore�get_running_looprr�__name__)rZprimitives_clsr$�clsrrr�&test_lock_doesnt_accept_loop_parameter2s&�������z0LockTests.test_lock_doesnt_accept_loop_parameterc�s��t��t��t��t��g}��t��tj�fdd��}Wd�n1s(wY|D]}||�IdH��|�	��q/dS)Nc	3s��t�d�EdH��|�����td��|EdH�Wd�n1s'wYWd�n1s6wY��|���dS)N�{�G�z�?r)r�sleeprr rrr�rrr�testNs�����z3LockTests.test_lock_by_with_statement.<locals>.test)
rr
r%r'r(rrrrr )rZ
primitivesr0rrr/r�test_lock_by_with_statementEs���
�z%LockTests.test_lock_by_with_statementc�sx�t���g}|����IdH��fdd�}�fdd�}�fdd�}t�||��}t�||��}t�d�IdH|�g|����t�d�IdH|�dg|�t�d�IdH|�dg|�t�||��}���t�d�IdH|�dd	g|����t�d�IdH|�gd
�|�|�|���|�|�	��|�|���|�|�	��|�|���|�|�	��dS)Nc������IdHr
|�d�dS�N�T�r�append��resultrrr�c1d��
z"LockTests.test_acquire.<locals>.c1c�r2�N�Tr5r7rrr�c2ir:z"LockTests.test_acquire.<locals>.c2c�r2�N�Tr5r7rrr�c3nr:z"LockTests.test_acquire.<locals>.c3rr4r<�r4r<r?)
rr
rr�create_taskr.�assertEqual�release�doner8�rr8r9r=r@�t1�t2�t3rrr�test_acquire^s:�zLockTests.test_acquirec�s��t��}|�|��IdH�t�|���}t���|j�|�tj	��
|IdHWd�n1s4wY|�
|j�dSr)rr
rrrBr)�	call_soon�cancel�assertRaises�CancelledErrorr�_waiters)rrZtaskrrr�test_acquire_cancel�s��zLockTests.test_acquire_cancelc�s"�t����fdd�}t����}t�|d|��}t�d�IdH|�����t�|dd��}t�d�IdH|�t	�j
�d�t�|dd��}t�d�IdH|�t	�j
�d�|�d�|��|��j
d�
��t�d�IdH|�����|�|���|�|�
��|IdHdS)	Nc�sJ����IdHz|dur|IdHW���dSW���dS���wr)rrD)�nameZblockerrrr�lockit�s��z*LockTests.test_cancel_race.<locals>.lockit�Ar�Br4�Cr<)rr
r)Z
create_futurerBr.rr rC�lenrO�
set_resultrL�	cancelledrrE)rrR�fa�ta�tb�tcrrr�test_cancel_race�s*�
zLockTests.test_cancel_racec�s�t��}t���d�d����fdd�}��fdd�}���IdHt�|���t�|��}t�|��}t�d�IdH|�|�|�tj��
�IdHWd�n1sXwY|�	�d�|�	�d�|�
���or|���|�
�t�d�IdH|�
|���dS)Nrc�s$��d7����IdH�d7�dS�Nr4)rr)�
call_countr�
lock_countrrrR�s�z2LockTests.test_cancel_release_race.<locals>.lockitcs������dSr)rLrDr)rrGrr�trigger�sz3LockTests.test_cancel_release_race.<locals>.triggerr4r?)rr)r
rrBr.rKrMrNrCrrXrErL)rr$rRrarHrIr)r_rr`rGr�test_cancel_release_race�s,�
�z"LockTests.test_cancel_release_racec�s��t��}|��IdH|�|���t�|���}t�d�IdH|�t|j	�d�t�|���}|�
�|��t�d�IdH|�|���|�|���|IdHdS)Nrr4)
rr
rrr rBr.rCrVrOrLrDrX)rrr[r\rrr�test_finished_waiter_cancelled�s�z(LockTests.test_finished_waiter_cancelledc�s�t��}|�t|j�dSr)rr
rM�RuntimeErrorrDrrrr�test_release_not_acquireds�z#LockTests.test_release_not_acquiredc��@�t��}|��IdH|�|���|��|�|���dSr)rr
rrr rDrrrrr�test_release_no_waiters��z!LockTests.test_release_no_waitersc	��p�t��}|�|���|4IdH�|�|���Wd�IdHn1IdHs*wY|�|���dSr)rr
rr rrrrr�test_context_managers�(�zLockTests.test_context_managerN)r*�
__module__�__qualname__rr"r,r1rJrPr]rbrcrergrjrrrrrs	3
/-rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
EventTestscCs�t��}|�t|��d��t�t|��}|�|�d�d�|�	�|�t|��d��|�t�t|���|j
�t�
��|�dt|�v�|�t�t|���dS)Nz[unset]>�extrasZunsetz[set]>�	waiters:1)rr&rrr
rrrC�group�setrOr6r�Mock)r�evrrrrr'szEventTests.test_reprc�s�t���|�����g}�fdd�}�fdd�}�fdd�}t�||��}t�||��}t�d�IdH|�g|�t�||��}���t�d�IdH|�gd�|�|�|�	��|�
|���|�|�	��|�
|���|�|�	��|�
|���dS)	Nc��"����IdHr|�d�dSdSr^��waitr6r7�rsrrr9;���z EventTests.test_wait.<locals>.c1c�rt)Nr<rur7rwrrr=?rxz EventTests.test_wait.<locals>.c2c�rt)Nr?rur7rwrrr@Crxz EventTests.test_wait.<locals>.c3r)r?r4r<)rr&r�is_setrBr.rCrqrrEZassertIsNoner8rFrrwr�	test_wait5s*�zEventTests.test_waitc�s.�t��}|��|��IdH}|�|�dSr)rr&rqrvr)rrs�resrrr�test_wait_on_setZs
�zEventTests.test_wait_on_setc�sn�t��}t�|���}t���|j�|�tj��
|IdHWd�n1s*wY|�	|j
�dSr)rr&rBrvr)rKrLrMrNrrO)rrsrvrrr�test_wait_cancelas��zEventTests.test_wait_cancelc�sH�t��}|�|���|��|�|���|��|�|���dSr)rr&rryrqr�clear)rrsrrr�
test_clearjs�zEventTests.test_clearc�s��t���g}�fdd�}t�||��}t�d�IdH|�g|�������|�����������|�dt	�j
��t�d�IdH|�dg|�|�dt	�j
��|�|���|�|�
��dS)Nc�r2r3rur7rwrrr9xr:z.EventTests.test_clear_with_waiters.<locals>.c1rr4)rr&rBr.rCrqr~rryrVrOrrEr8�rr8r9�trrwr�test_clear_with_waitersts$�z"EventTests.test_clear_with_waitersN)	r*rkrlrrzr|r}rr�rrrrrm%s%	
rmc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�ConditionTestsc�s��t���g}�fdd�}�fdd�}�fdd�}t�||��}t�||��}t�||��}t�d�IdH|�g|�|�����|����IdH���	�t�d�IdH|�g|�|�������
�t�d�IdH|�dg|�|�������	d	�t�d�IdH|�dg|�|�������
�t�d�IdH|�dd	g|�|�������
�t�d�IdH|�gd
�|�|�����|�|���|�|���|�|���|�|���|�|���|�|���dS)Nc��,����IdH���IdHr|�d�dSr3�rrvr6r7��condrrr9��
�
z$ConditionTests.test_wait.<locals>.c1c�r�r;r�r7r�rrr=�r�z$ConditionTests.test_wait.<locals>.c2c�r�r>r�r7r�rrr@�r�z$ConditionTests.test_wait.<locals>.c3rr4r<rA)
rr%rBr.rCrr rr�notifyrDrEr8rFrr�rrz�sN�
zConditionTests.test_waitc�s��t��}|��IdHt�|���}t���|j�|�tj	��
|IdHWd�n1s1wY|�
|j�|�|�
��dSr)rr%rrBrvr)rKrLrMrNrrOrr )rr�rvrrrr}�s��zConditionTests.test_wait_cancelc�s��t��}|��IdH|�|���t�|���}t�d�IdH|�|���|��IdH|�|���|�	�t�
��|j�t�
��|j
�z|IdHWn
tjy\Ynw|�|���dS�Nr)rr%rrr rBrvr.rr�r)rKrLrDrN)rr�Z	wait_taskrrr�test_wait_cancel_contested�s$��z)ConditionTests.test_wait_cancel_contestedc�s��d�t�����fdd�}t�|��}t�d�IdH���IdH���t�d�IdH|��t�d�IdH���t�d�IdH|�|�	��|���dS)NFc	�sR��4IdH�d����IdHWd�IdHdS1IdHs"wYdS�NT)rvr�r�Zwaitedrr�wait_on_cond�s
�.�zBConditionTests.test_wait_cancel_after_notify.<locals>.wait_on_condr)
rr%rBr.rr�rLrDrrX)rr��waiterrr�r�test_wait_cancel_after_notify�s�z,ConditionTests.test_wait_cancel_after_notifyc�sH�t��}|�t��|��IdHWd�dS1swYdSr)rr%rMrdrv�rr�rrr�test_wait_unacquireds
�"�z#ConditionTests.test_wait_unacquiredc�s��t���d��fdd��g}��fdd�}t�||��}t�d�IdH|�g|����IdH������t�d�IdH|�g|�d����IdH������t�d�IdH|�dg|�|�|�	��|�|�
��dS)	NFcs�Srrr)�presultrr�	predicatesz/ConditionTests.test_wait_for.<locals>.predicatec�s6����IdH����IdHr|�d����dSr3)r�wait_forr6rDr7)r�r�rrr9s�
z(ConditionTests.test_wait_for.<locals>.c1rTr4�rr%rBr.rCrr�rDrrEr8r�r)r�r�r�r�
test_wait_fors,�zConditionTests.test_wait_forc�sr�t��}|�dd��IdH}|�gd�|�|�t��|�dd��IdHWd�dS1s2wYdS)NcSsgd�S)NrArrrrr�<lambda>>sz9ConditionTests.test_wait_for_unacquired.<locals>.<lambda>rAcSsdS)NFrrrrrr�Bs)rr%r�rCrMrd)rr�r{rrr�test_wait_for_unacquired:s�"�z'ConditionTests.test_wait_for_unacquiredc�sX�t���g}�fdd�}�fdd�}�fdd�}t�||��}t�||��}t�||��}t�d�IdH|�g|����IdH��d����t�d�IdH|�dg|����IdH��d���d	����t�d�IdH|�gd
�|�|�|�	��|�|�
��|�|�	��|�|�
��|�|�	��|�|�
��dS)Nc��4����IdH���IdHr|�d����dSr3�rrvr6rDr7r�rrr9H��
z&ConditionTests.test_notify.<locals>.c1c�r�r;r�r7r�rrr=Or�z&ConditionTests.test_notify.<locals>.c2c�r�r>r�r7r�rrr@Vr�z&ConditionTests.test_notify.<locals>.c3rr4irAr�rFrr�r�test_notifyDs8�


zConditionTests.test_notifyc�s��t���g}�fdd�}�fdd�}t�||��}t�||��}t�d�IdH|�g|����IdH������t�d�IdH|�ddg|�|�|�	��|�|�
��|�|�	��|�|�
��dS)Nc�r�r3r�r7r�rrr9}r�z*ConditionTests.test_notify_all.<locals>.c1c�r�r;r�r7r�rrr=�r�z*ConditionTests.test_notify_all.<locals>.c2rr4r<)rr%rBr.rCr�
notify_allrDrrEr8)rr8r9r=rGrHrr�r�test_notify_allxs$�zConditionTests.test_notify_allcC�t��}|�t|j�dSr)rr%rMrdr�r�rrr�test_notify_unacquired��z%ConditionTests.test_notify_unacquiredcCr�r)rr%rMrdr�r�rrr�test_notify_all_unacquired�r�z)ConditionTests.test_notify_all_unacquiredc�s��t��}|�dt|�v�|�t�t|���|��IdH|�dt|�v�|j�t	�
��|�dt|�v�|�t�t|���|j�t	�
��|�dt|�v�|�t�t|���dS)N�unlockedr ro�	waiters:2)rr%rrrrrrOr6rrrr�rrrr�s�zConditionTests.test_reprc	�rir)rr%rr rr�rrrrj�s�(�z#ConditionTests.test_context_managerc�sP�d�fdd�	}|�IdH|t���IdHt��}||t�|��IdHdS)Nc	�s2�|dur	t��}|durt�|�}��|j|���|�����|���|4IdH���|�����|���Wd�IdHn1IdHsLwY��|�����|���|4IdH���|�����|���Wd�IdHn1IdHs�wY��|�����|���dSr)rr
r%ZassertIs�_lockrr r�rr�r/rr�f�s(�
(�(�z,ConditionTests.test_explicit_lock.<locals>.f)NN)rr
r%)rr�rrr/r�test_explicit_lock�s�z!ConditionTests.test_explicit_lockc�sN�t������j���fdd�}��fdd�}|�IdH|�IdHdS)Nc	�s����t��tj�d�Wd�n1swYt��}�|_|4IdH�.t�|�}��td��|��IdHWd�n1sGwYWd�IdHdS1IdHs]wYdS�Nr#z"is bound to a different event loop)	rMrrr
�_loopr%rrdrr��r$rrr�wrong_loop_in_lock�s��
��.�z?ConditionTests.test_ambiguous_loops.<locals>.wrong_loop_in_lockc	�s��t��}|4IdH�M��t��tj|�d�Wd�n1s#wYt�|�}�|_��td��|��IdHWd�n1sHwYWd�IdHdS1IdHs^wYdSr�)	rr
rMrr%r�rrdrvr�r�rr�wrong_loop_in_cond�s��
��.�z?ConditionTests.test_ambiguous_loops.<locals>.wrong_loop_in_cond)rZnew_event_loopZ
addCleanup�close)rr�r�rr�r�test_ambiguous_loops�s�z#ConditionTests.test_ambiguous_loopsc	�s��t��}|4IdH�.|�tj��tj|��dd�IdHWd�n1s)wYWd�IdHdS1IdHs?wYdS)Ng�?��timeout)rr%rM�TimeoutErrorr�rv)rZ	conditionrrr�test_timeout_in_block�s��.�z$ConditionTests.test_timeout_in_blockN)r*rkrlrzr}r�r�r�r�r�r�r�r�r�rrjr�r�r�rrrrr��s"?%
4$&r�c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�SemaphoreTestscCst�d�}|�|���dSr�)rr'rr �r�semrrr�test_initial_value_zeros
z&SemaphoreTests.test_initial_value_zeroc�s��t��}|�t|��d��|�t�t|���|��IdH|�t|��d��|�dt|�v�|�t�t|���|jdurGt	�
�|_|j�t�
��|�dt|�v�|�t�t|���|j�t�
��|�dt|�v�|�t�t|���dS)Nz[unlocked, value:1]>r	�waitersror�)rr'rrr
rrrrO�collections�dequer6rrrr�rrrrs �

zSemaphoreTests.test_reprc�s��t���|�d�j�|�t��tj�fdd��}Wd�n1s%wY|�td��|�IdHWd�n1sAwY|�	��
��|�d�j�dS)Nr4c3rrrr�r�rrr"rz3SemaphoreTests.test_semaphore.<locals>.acquire_lockz"'Semaphore' object is not iterable)rr'rC�_valuerrrrrrr r!rr�r�test_semaphores����zSemaphoreTests.test_semaphorecCs|�ttjd�dS)N���)rM�
ValueErrorrr'r/rrr�test_semaphore_value/sz#SemaphoreTests.test_semaphore_valuec�s��t�d��g}|����IdH�|����IdH�|������fdd�}�fdd�}�fdd�}�fdd	�}t�||��}t�||��}t�||��}t�d
�IdH|�dg|�|�����|�dt	�j
��|�d
�j�t�||��}	������|�d
�j�t�d
�IdH|�d
�j�|�dt	|��|�����|�dt	�j
��|�d
�j�|�|�
��|�|���|||	g}
d
d�|
D�}|�dt	|�����tj|
�IdHdS)Nr?c������IdH|�d�dSr3r5r7r�rrr9:r:z'SemaphoreTests.test_acquire.<locals>.c1c�r�r;r5r7r�rrr=?r:z'SemaphoreTests.test_acquire.<locals>.c2c�r�r>r5r7r�rrr@Dr:z'SemaphoreTests.test_acquire.<locals>.c3c�r�)N�Tr5r7r�rr�c4Ir:z'SemaphoreTests.test_acquire.<locals>.c4rr4r<cSs g|]}|��r|��r|�qSr)rEr8��.0r�rrr�
<listcomp>hs z/SemaphoreTests.test_acquire.<locals>.<listcomp>)rr'rrrr rBr.rCrVrOr�rDrEr8�gather)rr8r9r=r@r�rGrHrI�t4Z
race_tasksZ
done_tasksrr�rrJ2sF�

zSemaphoreTests.test_acquirec�s��t��}|��IdHt�|���}t���|j�|�tj��
|IdHWd�n1s1wY|�	|j
pEtdd�|j
D���dS)Ncs��|]}|��VqdSr�rE)r�r�rrr�	<genexpr>x��z5SemaphoreTests.test_acquire_cancel.<locals>.<genexpr>)rr'rrBr)rKrLrMrNrrO�all)rr�rrrrrPos���z"SemaphoreTests.test_acquire_cancelc�s��tjdd�}t�|���}t�|���}t�|���}t�|���}t�d�IdH|��|��|��t�d�IdHt�d�IdHtdd�||fD��}|�|d�|�	|�
��|�|�
��|��|��t�d�IdHdS)Nr��valuecsr�rr�r�rrrr��r�zCSemaphoreTests.test_acquire_cancel_before_awoken.<locals>.<genexpr>r4)rr'rBrr.rLrD�sumrCrrEr)rr�rGrHrIr�Znum_donerrr�!test_acquire_cancel_before_awokenzs&�z0SemaphoreTests.test_acquire_cancel_before_awokenc�s��tjdd�}t�|���}t�|���}t�d�IdH|��|��t�d�IdHt�d�IdH|�|���|�|�	��dS)Nrr�)
rr'rBrr.rLrDrr rE)rr�rGrHrrr�test_acquire_hang�s�z SemaphoreTests.test_acquire_hangc�s��t�d����fdd�}��fdd�}t�|��}t�|���tj|�dd�IdH\}}��|du���t|tj��tj���dd	�IdHdS)
Nr4c	�sV��4IdH�t�d�IdHWd�IdHn1IdHs wY���dSr�)rr.rLr)r�rHrrr9�s
�(�z/SemaphoreTests.test_acquire_no_hang.<locals>.c1c	�sJ��4IdH���d�Wd�IdHdS1IdHswYdSr�)rrr�rrr=�s�.�z/SemaphoreTests.test_acquire_no_hang.<locals>.c2T)�return_exceptionsg�?r�)	rr'rBr�r�
isinstancerNr�r)rr9r=rGZr1Zr2r)rr�rHr�test_acquire_no_hang�s�
z#SemaphoreTests.test_acquire_no_hangcCr�r)rr(rMr�rDr�rrrre�sz(SemaphoreTests.test_release_not_acquiredc�rfr)rr'rrr rDrr�rrrrg�rhz&SemaphoreTests.test_release_no_waitersc�sp�t�d��g���fdd�}t�|d��}t�|d��}t�|d��}t�|||�IdH|�gd���dS)Nr4c�sr����IdH��|�d��t�d�IdH������IdH��|�d��t�d�IdH���dS)NZ_1r-Z_2)rr6rr.rD)�tag�r8r�rr�coro�s�z4SemaphoreTests.test_acquire_fifo_order.<locals>.coror9r=r@)Zc1_1Zc2_1Zc3_1Zc1_2Zc2_2Zc3_2)rr'rBr�rC)rr�rGrHrIrr�r�test_acquire_fifo_order�s�
�z&SemaphoreTests.test_acquire_fifo_orderc	�s��t�d��g}�fdd�}�fdd�}�fdd�}t�||��}t�||��}t�||��}t�d�IdH������|||g}tj|�IdH|�gd	�|�dS)
Nr4c�r�r3r5r7r�rrr9�r:z4SemaphoreTests.test_acquire_fifo_order_2.<locals>.c1c�s>����IdH|�d�������IdH|�d�dS)Nr<r�T)rr6rDr7r�rrr=�s�

z4SemaphoreTests.test_acquire_fifo_order_2.<locals>.c2c�r�r>r5r7r�rrr@�r:z4SemaphoreTests.test_acquire_fifo_order_2.<locals>.c3r)r4r<r?r�)rr'rBr.rDr�rC�	rr8r9r=r@rGrHrIZtasksrr�r�test_acquire_fifo_order_2�s�

z(SemaphoreTests.test_acquire_fifo_order_2c	�s��t�d��g}�fdd�}�fdd�}�fdd�}t�||��}t�||��}t�||��}t�d�IdH|��t�d�IdH������|||g}tj|dd	i�IdH|�d
dg|�dS)Nrc�r�r3r5r7r�rrr9r:z4SemaphoreTests.test_acquire_fifo_order_3.<locals>.c1c�r�r;r5r7r�rrr=
r:z4SemaphoreTests.test_acquire_fifo_order_3.<locals>.c2c�r�r>r5r7r�rrr@r:z4SemaphoreTests.test_acquire_fifo_order_3.<locals>.c3r�Tr<r?)rr'rBr.rLrDr�rCr�rr�r�test_acquire_fifo_order_3s"�

z(SemaphoreTests.test_acquire_fifo_order_3N)r*rkrlr�rr�r�rJrPr�r�r�rergr�r�r�rrrrr�s=#r��__main__)�__doc__Zunittestr�rerr�ZSTR_RGX_REPR�compilerrZIsolatedAsyncioTestCaserrmr�r�r*�mainrrrr�<module>s.�
ls&�