Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
locks_test.cpython-313.pyc100 linesDownload Raw Back to __pycache__
1�

2��j}D���SSKrSSKJr SSKrSSKrSSKJrJr SSKJ	r	 SSK3JrJr "SS\5r
"SS	\5r"S4S\5r"SS
\5r"SS\5r"SS\5r\S:Xa\R("5 gg)�N)�	timedelta)�gen�locks)�TimeoutError)�gen_test�
AsyncTestCasec�^�\rSrSrU4SjrSrSrSr\S5r	Sr5SrS	r\S65r
\S5r\S5r\S
5r\S5r\S5rSrU=r$)�
ConditionTest�c�0>�[TU]5 /Ulg�N)�super�setUp�history)�self�	__class__s ��]D:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/test/locks_test.pyr�ConditionTest.setUps���
��
�����c�<^^^�UUU4SjnTRU5 g)z=Record the resolution of a Future returned by Condition.wait.c�>�TR5(dTRRS5 gTRRT5 g)N�timeout)�resultr�append)�_�future�keyrs ���r�callback�+ConditionTest.record_done.<locals>.callbacks2����=�=�?�?����#�#�I�.����#�#�C�(rN)�add_done_callback)rrrrs``` r�record_done�ConditionTest.record_dones���	)�	� � ��*rc�n�URRUR5 UR5 g)z�Run all queued callbacks on the IOLoop.7 8In these tests, this method is used after calling notify() to9preserve the pre-5.0 behavior in which callbacks ran10synchronously.11N)�io_loop�add_callback�stop�wait�rs r�loop_briefly�ConditionTest.loop_briefly(s#��	
���!�!�$�)�)�,��	�	�rc���[R"5nURS[U55 UR	S[U55 UR5 URS[U55 g)N�	Condition�waiters)rr,�assertIn�repr�assertNotInr'�r�cs  r�	test_repr�ConditionTest.test_repr2sO���O�O����
�
�k�4��7�+�����D��G�,�	�����
�
�i��a��)rc#�# �[R"5nURRSUR5 UR5v� g7f)N�{�G�z�?)rr,r$�12call_later�notifyr'r1s  r�test_notify�ConditionTest.test_notify9s4����O�O���������a�h�h�/��f�f�h��s�AAc���[R"5nURUR5S5 URUR5S5 UR	S5 UR5 URRS5 UR	S5 UR5 URRS5 UR/SQUR5 g)N�wait1�wait2��notify1�notify2)r<r?r=r@)	rr,r!r'r8r)rr�assertEqualr1s  r�
test_notify_1�ConditionTest.test_notify_1?s����O�O����������7�+��������7�+�	��������������I�&�	��������������I�&����A�4�<�<�Prc�l�[R"5n[S5H#nURUR	5U5 M% URS5 UR
5 UR[[S55UR5 URS5 UR
5 UR[[S55UR5 URS5 UR
5 UR[[S55UR5 g)N��r>��)13rr,�ranger!r'r8r)rA�listr�rr2�is   r�
test_notify_n�ConditionTest.test_notify_nKs����O�O����q��A����Q�V�V�X�q�)��	14���������	
����e�A�h�����6�	�������������e�A�h�����6�	�������������e�A�h�����6rc�l�[R"5n[S5H#nURUR	5U5 M% UR5 UR
5 URRS5 UR[[S55S/-UR5 g)NrG�15notify_all)rr,rIr!r'rPr)rrrArJrKs   r�test_notify_all�ConditionTest.test_notify_all\s����O�O����q��A����Q�V�V�X�q�)��	16�������������L�)�	
����e�A�h��<�.�8�$�,�,�Grc#�# �[R"5nUR[SS95nURRSUR5 [R"S5v� URUv�5 g7f)Nr6��seconds�{�G�z�?���Q��?)17rr,r'rr$r7r8r�sleep�assertFalse�rr2r's   r�test_wait_timeout�ConditionTest.test_wait_timeouthsZ����O�O����v�v�i��-�.��������a�h�h�/��i�i��o������*�&�s�BBc#��# �[R"5nURRSUR5 UR[
SS95n[R"S5v� Uv� g7f)Nr6rVrTrW)	rr,r$r7r8r'rrrXrZs   r�test_wait_timeout_preempted�)ConditionTest.test_wait_timeout_preemptedpsQ����O�O���	
������a�h�h�/��v�v�i��-�.���i�i��o���18�s�A1A3c#��# �[R"5nURUR5S5 URUR[	SS95S5 URUR5S5 URUR5S5 [19R"S5v� URS/UR5 URS5 [20R"S5v� UR/S	QUR5 UR/S	QUR5 UR5 Sv� UR/S21QUR5 g7f)Nrr6rTr>rHrFrVr�rrrH)rrrHrF)22rr,r!r'rrrXrArr8r1s  r�test_notify_n_with_timeout�(ConditionTest.test_notify_n_with_timeoutzs����
�O�O����������1�%�������	�$� 7�8�!�<��������1�%��������1�%��i�i��o�����)��d�l�l�3�	������i�i��o�����*�D�L�L�9����*�D�L�L�9�	���23�
����-�t�|�|�<�s�E+E-c#��# �[R"5nURUR5S5 URUR[	SS95S5 URUR5S5 [24R"S5v� URS/UR5 UR5 Sv� UR/SQUR5 g7f)	Nrr6rTr>rHrVrra)25rr,r!r'rrrXrArrPr1s  r�test_notify_all_with_timeout�*ConditionTest.test_notify_all_with_timeout�s�����O�O����������1�%�������	�$� 7�8�!�<��������1�%��i�i��o�����)��d�l�l�3�	����
����*�D�L�L�9�s�C&C(c#�X^# �[R"5m[S5Vs/sH'n[R"TR55PM) nnUSR
U4Sj5 TRS5 Sv� UR[SU555 gs snf7f)NrFr>c�$>�TR5$r
)r8)rr2s �r�<lambda>�2ConditionTest.test_nested_notify.<locals>.<lambda>�s���q�x�x�zrrHc3�@# �UHoR5v� M g7fr
��done)�.0�fs  r�	<genexpr>�3ConditionTest.test_nested_notify.<locals>.<genexpr>�s���6�g��F�F�H�H�g���)26rr,rI�asyncio�
ensure_futurer'r r8�27assertTrue�all)rr�futuresr2s   @r�test_nested_notify� ConditionTest.test_nested_notify�s�����
�O�O���=B�!�H�E�H�q�7�(�(�����2�H��E�	��28�$�$�%9�:�	�����
�����6�g�6�6�7��F�s�#B*�.B%�AB*c#�2# �[R"5n[S5HnUR[	SS95 M [29R"UR55nURS[UR55 [R"S5v� URS[UR55 URUR55 UR5 URUR55 g7f)N�er6rT�frVr>)rr,rIr'rrsrtrA�len�_waitersrrXrYrmr8ru)rr2rrs    r�test_garbage_collection�%ConditionTest.test_garbage_collection�s����
�O�O����s��A�
�F�F�9�T�*�+���&�&�q�v�v�x�0������c�!�*�*�o�.��i�i��o������C��30�31�O�,�	
�������'�	���32�������
�&�s�DD)r)�__name__�33__module__�__qualname__�__firstlineno__rr!r)r3rr9rBrMrQr[r^rbrerxr�__static_attributes__�
__classcell__)rs@rr34r35s�����36+��*�����37 38Q�7�"39H��'��'������=��=�.�:��:��
8��
8��'��'rr40c�<�\rSrSrSrSr\S5rSrSr	Sr41g)	�	EventTest��c�6�[R"5nURS[U5;5 UR	S[U5;5 UR5 UR	S[U5;5 URS[U5;5 g)N�clear�set)r�Eventru�strrYr�)r�events  rr3�EventTest.test_repr�sn�����
������3�u�:�-�.�����#�e�*�,�-�
�	�	������C��J�.�/������U��+�,rc��[R"5n[R"UR	55nUR5 [R"UR	55nUR
5 [R"UR	55nURUR55 URUR55 URUR55 gr
)42rr�rsrtr'r�r�rurmrY)r�e�future_0�future_1�future_2s     r�43test_event�EventTest.test_event�s����K�K�M���(�(�����2��	�����(�(�����2��	���	��(�(�����2������
�
��(�����
�
��(��������)rc#�V# �[R"5nUR[5 UR	[SS95v� SSS5 URR[SS9UR5 UR	[SS95v� g!,(df   NV=f7f)Nr6rTr>)	rr��assertRaisesrr'rr$�add_timeoutr��rr�s  r�test_event_timeout�EventTest.test_event_timeout�sr����K�K�M��
�
�
�|�
,��&�&��4�0�1�1�-�	
��� � ��4�!8�!�%�%�@��f�f�Y�q�)�*�*�-�
,�s�+B)�B�AB)�44B&�"B)c��[R"5nUR5 UR5 URUR	55 gr
)rr�r�ru�is_setr�s  r�test_event_set_multiple�!EventTest.test_event_set_multiple�s1���K�K�M��	����	����������45�#rc�z�[R"5n[R"UR	55nUR5 [R"UR	55nUR
5 URUR55 URUR55 gr
)	rr�rsrtr'r�r�rurm)rr��f0�f1s    r�test_event_wait_clear�EventTest.test_event_wait_clear�so���K�K�M��
�
"�
"�1�6�6�8�
,��	���	�
�
"�
"�1�6�6�8�
,��	����������	�"�������	�"r�N)r�r�r�r�r3r�rr�r�r�r�r�rrr�r��s*��-�46*��+��+�$�#rr�c�\�\rSrSrSrSrSr\S5r\S5r	Sr47\S5rS	rg48)�
SemaphoreTest��c�J�UR[[RSS9 g)N�������value)r��49ValueErrorr�	Semaphorer(s r�test_negative_value�!SemaphoreTest.test_negative_value�s�����*�e�o�o�R��@rc�|�[R"5nURS[U55 URS[U55 UR	5 URS[U55 URS[U55 UR	5 URS[U55 g)Nr�zunlocked,value:1�lockedr-)rr�r.r/�acquirer0�r�sems  rr3�SemaphoreTest.test_repr�s}���o�o����
�
�k�4��9�-��
�
�(�$�s�)�4����
��
�
�h��S�	�*�����D��I�.����
��
�
�i��c��+rc�h�[R"5n[R"UR	55nURUR
55 [R"UR	55nURUR
55 [R"UR	55nUR5 URUR
55 URUR
55 UR5 URUR
55 UR5 UR[R"UR	55R
55 URS[UR55 g)Nr)rr�rsrtr�rurmrY�releaserAr}r~)rr�r�r��f2s     r�test_acquire�SemaphoreTest.test_acquires50���o�o���
�
"�
"�3�;�;�=�
1��������	�"��
"�
"�3�;�;�=�
1���������#�
�
"�
"�3�;�;�=�
1�����
�������	�"��������#����
�������	�"����
�����-�-�c�k�k�m�<�A�A�C�D�����C����-�.rc#�# �[R"S5nUR5v� UR5v� UR[SS95nURRSUR5 [R"S5v� UR[R5 Uv� SSS5 UR5 [R"UR55nURUR55 UR
5 URUR55 g!,(df   N�=f7f)NrHr6rTrVg333333�?)rr�r�rr$r7r�rrXr�rrsrtrYrmru)rr�r�ros    r�test_acquire_timeout�"SemaphoreTest.test_acquire_timeouts�����o�o�a� ���k�k�m���k�k�m���+�+�i��5�6��������c�k�k�2��i�i��n��
�
�
�s�/�/�
0��M�1�	���
��!�!�#�+�+�-�0���������"����
��������!�1�
0�s�B0E�2E�7BE�51E�Ec#�# �[R"S5nUR5v� URR	SUR525 UR[
SS95n[R"S5v� Uv� g7f)Nr>r6rVrTrW)	rr�r�r$r7r�rrrX)rr�r�s   r�test_acquire_timeout_preempted�,SemaphoreTest.test_acquire_timeout_preempted's_����o�o�a� ���k�k�m��	
������c�k�k�2��+�+�i��5�6���i�i��o���
�s�BBc�v�[R"5nUR5 UR5 UR[R53"UR
55R55 UR[R54"UR
55R55 UR[R55"UR
55R55 UR[R56"UR
55R55 gr
)	rr�r�rursrtr�rmrYr�s  r�test_release_unacquired�%SemaphoreTest.test_release_unacquired2s����o�o������
����
�	
����-�-�c�k�k�m�<�A�A�C�D�����-�-�c�k�k�m�<�A�A�C�D�����-�-�c�k�k�m�<�A�A�C�D�����.�.�s�{�{�}�=�B�B�D�Erc#��# �[R"SS9n[S5Vs/sH/n[R"UR[
SS955PM1 nn[R"UR55nURS[UR55 [R"S5v� URS[UR55 URUR55 UR5 URUR55 UH#nUR!["UR$5 M% gs snf7f)	Nrr�r{r6rTr|rVr>)rr�rIrsrtr�rrAr}r~rrXrYrmr�rur�rr)rr�rrwrs     rr�%SemaphoreTest.test_garbage_collection>s����o�o�A�&���3�Z�57���
�!�!�#�+�+�i��.E�"F�G��	�58�59�&�&�s�{�{�}�5������c�#�,�,�/�0��i�i��o������C����-�.�	
�������'����
�������
�&��F����l�F�M�M�:���%60�s�"E�6E�DEr�N)
r�r�r�r�r�r3r�rr�r�r�rr�r�rrr�r��sT��A�,�/�(�"��"� ����61F��;��;rr�c��\rSrSr\S5r\S5r\S5r\S5r\S5r	\S5r62\S5rS	rS63r
g)�SemaphoreContextManagerTestiXc#�2# �[R"5nUR5v�nURU5 SSS5 UR	[64R"UR55R55 g!,(df   NP=f7fr
)rr�r��assertIsNonerursrtrm)rr��yieldeds   r�test_context_manager�0SemaphoreContextManagerTest.test_context_managerYsb����o�o����K�K�M�!�g����g�&�"�	
����-�-�c�k�k�m�<�A�A�C�D�	"�!�s�(B�B�A65B�66B�Bc#��^^# �[R"5mUU4SjnU"5v� TR[R"TR55R
55 g7f)Nc��># �TIShv�NnTRU5 SSS5IShv�N gN&N!,IShv�N(df   g=f7fr
)r�)r�rr�s ��rro�GSemaphoreContextManagerTest.test_context_manager_async_await.<locals>.fgs*�����s�g��!�!�'�*��s�s�s�s�s��9�A�1�A�5�A�3�A�A�A�>�A�A)rr�rursrtr�rm)rror�s` @r� test_context_manager_async_await�<SemaphoreContextManagerTest.test_context_manager_async_awaitbsJ�����o�o���	+��c�	�	
����-�-�c�k�k�m�<�A�A�C�D�s�A(A,c#�x# �[R"5nUR[5 UR	5v� SS- SSS5 SSS5 UR[R"UR	55R55 g!,(df   NX=f!,(df   Na=f7f)Nr>r)	rr�r��ZeroDivisionErrorr�rursrtrmr�s  r�test_context_manager_exception�:SemaphoreContextManagerTest.test_context_manager_exceptionpsv����o�o���
�
�
�0�
1����
�%��A��&�2�67	
����-�-�c�k�k�m�<�A�A�C�D�	&�%��2�
1�s5�+B:�B)�B�B)�A68B:�69B&	�"B)�)70B7�3B:c#�"# �[R"5nUR[SS95v� SSS5 UR	[71R"UR55R55 g!,(df   NP=f7f)Nr6rT)rr�r�rrursrtrmr�s  r�test_context_manager_timeout�8SemaphoreContextManagerTest.test_context_manager_timeoutzs]����o�o����K�K�	�$� 7�8�8��9�	
����-�-�c�k�k�m�<�A�A�C�D�	9�8�s�0B�A>�A72B�>73B�Bc#�# �[R"SS9nUR[R5 UR[
SS95v� SSS5 SSS5 UR[R"UR55R55 g!,(df   NX=f!,(df   Na=f7f)Nrr�r6rT)rr�r�rrr�rrYrsrtrmr�s  r�"test_context_manager_timeout_error�>SemaphoreContextManagerTest.test_context_manager_timeout_error�s�����o�o�A�&��
�
�
�s�/�/�
0����I�d�$;�<�<��=�1�74	
����.�.�s�{�{�}�=�B�B�D�E�	=�<��1�
0�s5�4C�B6�B%�B6�A75C�%76B3	�/B6�677C�Cc#�@^^# �[R"5m/m[RUU4Sj5n[	S5Vs/sH78o!"U5PM snv� /n[	S5HnURSU-SU-/5 M UR
UT5 gs snf7f)Nc3��># �TR5v� TRSU-5 [R"S5v� TRSU-5 SSS5 g!,(df   g=f7f)N�acquired %dr6�79release %d)r�rrrX)�indexrr�s ��rro�ESemaphoreContextManagerTest.test_context_manager_contended.<locals>.f�sM�������
�%����}�u�4�5��i�i��o�%����|�e�3�4�&�%�%�s�A1�AA �	A1� 80A.�*A1rHr�r�)rr�r�	coroutinerI�extendrA)rrorL�expected_historyrr�s    @@r�test_context_manager_contended�:SemaphoreContextManagerTest.test_context_manager_contended�s������o�o�����	���	5�81�	5�#�1�X�&�X��q��t�X�&�&����q��A��#�#�]�Q�%6��q�8H�$I�J��	
���)�7�3��
'�s�?B�B�A82Bc#��# �UR[R5 [R"5v� SSS5 SSS5 g!,(df   N=f!,(df   g=f7fr
)r�r�
BadYieldErrorrr�r(s r�test_yield_sem�*SemaphoreContextManagerTest.test_yield_sem�sG����
�
�s�0�0�
1����)�)��*�2�
1�)�)��2�
1��2� A/�A�A
�A�	A/�
83A	�A�84A,�(A/c���UR[5 [R"5 SSS5 SSS5 g!,(df   N=f!,(df   g=fr
)r��RuntimeErrorrr�r(s r�test_context_manager_misuse�7SemaphoreContextManagerTest.test_context_manager_misuse�s<���
�
�|�
,����"��#�-�
,�"�"��-�
,���A�?�A�85A
	�	A�86Ar�N)r�r�r�r�rr�r�r�r�r�r�r�r�r�r�rrr�r�Xs���
�E��E��E��E��E��E��E��E��F��F��4��4�&����rr�c��\rSrSrSrSrg)�BoundedSemaphoreTesti�c���[R"5nUR[UR5 UR5 [R"UR55nURUR55 UR	5 URUR55 UR	5 UR[UR5 gr
)r�BoundedSemaphorer�r�r�r�rsrtrYrmru)rr�rs   rr��,BoundedSemaphoreTest.test_release_unacquired�s����$�$�&�����*�c�k�k�2����
��&�&�s�{�{�}�5���������'����
�������
�&����
����*�c�k�k�2rr�N)r�r�r�r�r�r�r�rrr�r��s��3rr�c�l�\rSrSrSrSr\S5r\S5r\S5r	Sr87\S5rS	rS88r
g)�	LockTestsi�c�z�[R"5n[U5 UR5 [U5 gr
)r�Lockr/r��r�locks  rr3�LockTests.test_repr�s$���z�z�|���T�89������T�90rc��[R"5nUR[R"UR55R
55 [R"UR55nURUR
55 UR5 URUR
55 gr
)	rr�rursrtr�rmrYr�)rr�rs   r�test_acquire_release�LockTests.test_acquire_release�sx���z�z�|������-�-�d�l�l�n�=�B�B�D�E��&�&�t�|�|�~�6���������'�����������
�&rc#��^^# �[R"5mUR[R"TR55R
55 Sn/m[RUU4Sj5n[U5Vs/sH91o2"U5PM nnUR[SU555 TR5 Uv� UR[[U55T5 gs snf7f)N�c3�># �TR5v� TRU5 SSS5 g!,(df   g=f7fr
)r�r��idxrr�s ��rro�&LockTests.test_acquire_fifo.<locals>.f�s)��������&����s�#�'�&�&�s�A�1�	A�92?�Ac3�@# �UHoR5v� M g7fr
rl)rnrs  rrp�.LockTests.test_acquire_fifo.<locals>.<genexpr>�s���A��v�[�[�]�]��rr)rr�rursrtr�rmrr�rIrY�anyr�rArJ�r�NrorLrwrr�s     @@r�test_acquire_fifo�LockTests.test_acquire_fifo�s������z�z�|������-�-�d�l�l�n�=�B�B�D�E�
����	���	$�93�	$�"'�q��*��A�1�Q�4���*�����A��A�A�B������
�����e�A�h���1��	+�s�BC8�C3�A!C8c#�^^# �[R"5mUR[R"TR55R
55 Sn/mUU4Sjn[U5Vs/sH94o2"U5PM nnTR5 Uv� UR[[U55T5 gs snf7f)Nrc��># �TIShv�N TRU5 SSS5IShv�N gN&N!,IShv�N(df   g=f7fr
)rrs ��rro�1LockTests.test_acquire_fifo_async_with.<locals>.f�s&�����t����s�#��t�t�t�t�t�r�)rr�rursrtr�rmrIr�rArJr
s     @@r�test_acquire_fifo_async_with�&LockTests.test_acquire_fifo_async_with�s������z�z�|������-�-�d�l�l�n�=�B�B�D�E�
����	$�"'�q��*��A�1�Q�4���*������
�����e�A�h���1��+�s�A/C�3B?�ACc#�z# �[R"5nUR5 UR[R955 UR[
SS9S9v� SSS5 UR[R"UR55R55 g!,(df   NP=f7f)Nr6rT)r)rr�r�r�rrrrYrsrtrmr�s  rr��LockTests.test_acquire_timeout�sz����z�z�|������
�
�
�s�/�/�
0��,�,�y��'>�,�?�?�1�	
����.�.�t�|�|�~�>�C�C�E�F�	1�
0�s�AB;�B*� A96B;�*97B8�4B;c���[R"5nUR[UR5 UR5 UR	5 UR[UR5 gr
)rr�r�r�r�r�r�s  r�test_multi_release�LockTests.test_multi_release�sG���z�z�|�����,����5������������,����5rc#��# �UR[R5 [R"5v� SSS5 SSS5 g!,(df   N=f!,(df   g=f7fr
)r�rr�rr�r(s r�test_yield_lock�LockTests.test_yield_locksF����
�
�s�0�0�
1��98�99��$��%�2�
1�$�$��2�
1�r�c���UR[5 [R"5 SSS5 SSS5 g!,(df   N=f!,(df   g=fr
)r�r�rr�r(s rr��%LockTests.test_context_manager_misuses:���
�
�|�
,�������-�
,����-�
,�r�r�N)r�r�r�r�r3rrrrr�rrr�r�r�rrr�r��sh���'��2��2�"�2��2�"�G��G�6�����rr��__main__)rs�datetimer�typing�unittest�tornadorr�tornado.genr�tornado.testingrrr100r�r�r�r�r�r��mainr�rr�<module>r(s�����
���$�3�k'�M�k'�\,#�
�,#�^a;�M�a;�HV�-�V�r
3�=�
3� R�
�R�j�z���M�M�O�r
codekingpro/portable-devtools · Team Ai