403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python315/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python315/Lib/test/__pycache__/test_threading.cpython-315.opt-1.pyc
R
>lqjW�c��Qs]PHs]QHGsGsGs]QHGsGsGs]QH$G
s
Gs]QH0G
s
GsGs]QHGs]PHDs]PHHs]PHLs]PHPs]PHTs]PHXs]PH\s]PH`s]PHds]PHhs]PHls]PHps]PHts]QHXGs]QHGs]QHG s ]Q	H�G"s"\OHP	Q
5Q>s%Qs&Qs'Q
s(QQ\)2s*QQ\OV2s,QQ\OZ2s.QQ\.2s/QQ\.2s0QQ\.2s1QQ\.2s2QQ\OV2s3QQ\.2s4Q Q!\.2s5Q"Q#\Ol2s6Q$Q%\On2s8\Or\OtPIQ&2Q'Q(\On22s;Q)Q*\Ox2s<Q+Q,\On2s=Q-Q.\O|2s>Q/Q0\O~2s?Q1Q2\O�2s@Q3Q4\O�2sAQ5Q6\.2sBQ7Q8\OZ2sCQ9Q:\OZ2sDQ;Q<\OZ2sE\FQ=6Xc\O�2P!P!\#cPs"CK�h9h)?z!
Tests for the threading module.
)�threading_helper�requires_subprocess�requires_gil_enabled)�verbose�cpython_only�	os_helper)�ensure_lazy_imports�
import_module)�assert_python_ok�assert_python_failure�spawn_python)�force_not_colorized)�mock)�
lock_tests)�support)�interpreters)�modulec��[O%f[OQ2U2![O
[7c[OQ2U2![O%c[OQ2U2![OP	Q5%c[OQ2U2!U!)zrequires working os.fork()z*due to known OS bug related to thread+forkz?libasan has a pthread_create() dead lock related to thread+fork��threadz'TSAN doesn't support threads after fork)	r�has_fork_support�unittest�skip�sys�platform�platforms_to_skip�HAVE_ASAN_FORK_BUG�check_sanitizer)�tests&�(C:\Python315\\Lib\test\test_threading.py�skip_unless_reliable_forkr,s����#�#�#��}�}�9�:�4�@�@�
�|�|�(�(��}�}�I�J�4�P�P��!�!�!��}�}�^�_�`d�e�e����d�+�+��}�}�F�G��M�M��K�c�J�[O[PIQ2U2!)z>Decorator to skip a test if subinterpreters are not supported.zsubinterpreters required)r�skipIfr)�meths&r�requires_subinterpretersr$8s%���?�?�<�4�/�5�7�7;�=�=r c��UO[[Q[O2[O[mP!)�
excepthook)�
addCleanup�setattr�	threadingr&�__excepthook__)�testcases&r�restore_default_excepthookr,>s*�������L�)�:N�:N�O�$�3�3�I�r c�:`�\sQs]DsnQsQsQsQsQsUs	P!)�Counterc��]UmP!����value��selfs&r�__init__�Counter.__init__Es	����
r c�:�U9O]*
tmP!��r2r4s&r�inc�Counter.incG����
�
�a��
r c�:�U9O]*tmP!r9r2r4s&r�dec�Counter.decIr=r c��UO!�Nr2r4s&r�get�Counter.getKs���z�z�r r2)
�__name__�
__module__�__qualname__�__firstlineno__r6r;r?rC�__static_attributes__�__classdictcell__��
__classdict__s@rr.r.Ds��������r r.c�.`�\sQs]NsnQsQsQsUsP!)�
TestThreadc�x�[OOVQ5V mV0mV@mVPmP!)��name)r)�Threadr6r+�sema�mutex�nrunning)r5rQr+rSrTrUs&&&&&&rr6�TestThread.__init__Os-�����!�!�$�!�2� �
��	��
� �
r c
�T�[O2Q*o[%c&[QUOUQ*1*2UO9^tt^2UO
9^tt^2UOO2[%c%[UOO2Q2UOOUOO2]2PPP2[OU2[%c[QUOQ2UO
9^tt^2UOO2UOOUOO2]2[%c7[QUOUOO21*2PPP2PPP2P!)%fhCK9h)%fhK.9h)%fhP!9h)g��@ztask %s will run for %.1f usecg��.Aztasks are running�task�donez$%s is finished. %d tasks are running)�randomr�printrQrSrTrUr;rCr+�assertLessEqual�time�sleepr?�assertGreaterEqual)r5�delays& r�run�TestThread.runVsO���
�
��'�)���7��2��9�9�e�c�k�*�+�
,��Y�Y�Y������
�
�!�!�#��7��$�-�-�+�+�-�/B�C��
�
�-�-�d�m�m�.?�.?�.A�1�E�	�
�J�J�u���w��f�d�i�i��0������
�
�!�!�#��
�
�0�0����1B�1B�1D�a�H��7��@��9�9�d�m�m�&7�&7�&9�:�;�<�	��Y���������Y�Y�sb�#H�8&G/	�AG/	�7)H�!+H�AH	�'6H	�H�/H
�8H
�:	H�H
�H
�H�H'	�H'	)rTrUrSr+)rErFrGrHr6rarIrJrKs@rrNrNNs����!�<�<r rNc�.`�\sQs]osnQsQsQsUsP!)�BaseTestCasec�<�[O2UmP!rB)r�threading_setup�_threadsr4s&r�setUp�BaseTestCase.setUpps��(�8�8�:��
r c��[OUO[OO2P!rB)r�threading_cleanuprgrr�
reap_childrenr4s&r�tearDown�BaseTestCase.tearDownss$���*�*�D�M�M�:����"�"�$r )rg)rErFrGrHrhrmrIrJrKs@rrdrdos����;�%�%r rdc�`�\sQs]xsnQs\Q2s\Q2sQsQs	Qs
QsQsQ	s
Q
sQsQs\Q
2s\\O&\\Q2Q2\O&\\Q2Q2Q222sQsQsQsQsQs\O:]QCP
Q5Q2sQsQs Qs!Qs"Qs#\$Q2s%\$Q 2s&Q!s'\$\O&\\(Q"2Q#2Q$22s)\$\O&\\(Q"2Q#2Q%22s*\$\O&\\(Q"2Q#2QDQ&k22s+QDQ'ks,Q(s-Q)s.Q*s/Q+s0\Q,2s1Q-s2Q.s3Q/s4Q0s5Q1s6Q2s7Q3s8Q4s9Q5s:Q6s;Q7s<\OzQ8Q9Q:,2Q;2s>Q<s?\Q=2s@\$\O&\\AQ>2Q?2Q@22sBQAsCQBsDUsEP!)E�ThreadTestsi'c�$�[QQQ.2P!)r)�	functools�warnings)rr4s&r�test_lazy_import�ThreadTests.test_lazy_import{s���K�+�z�)B�Cr c�.�Qo[OQQ5oUOUOQ2[O]{Q5oUOUOQ2[OUQQ5oUOUOQ2[O
O
[Q]Q59^tt^2[OPQ5oUOUOQ2PPP2[O
O
[Q]Q59^tt^2[O2oUOUOQ	2PPP2[O
O
[Q]Q59^tt^2[OUQ
5oUOUOQ2PPP2P!)%fhK�9h)%fhK�9h)%fhP!9h)c��P!rB�rxr r�func�#ThreadTests.test_name.<locals>.func����Dr �myname1rP�123�myname2��targetrQ�_counter)�return_valuezThread-2zThread-3�r�zThread-5 (func))r)rR�assertEqualrQr
�patch�object)r5ryrs&  r�	test_name�ThreadTests.test_namesp����!�!�y�1��������i�0��!�!�s�+��������e�,��!�!��I�>��������i�0�
�Z�Z�
�
�y�*�1�
�
E�
E��%�%�2�.�F����V�[�[�*�5�F��Z�Z�
�
�y�*�1�
�
E�
E��%�%�'�F����V�[�[�*�5�F��Z�Z�
�
�y�*�1�
�
E�
E��%�%�T�2�F����V�[�[�*;�<�F�
E�F�
E��F�
E��F�
E�
E�s6�
4G�72G0�4H�G-	�&G-	�0H	�9H	�H	�H	c	�x`�],oQ	oQ,oQ
o],1oQ	,oUU1Qk1UU1Qk1UU1Qk1UU1Qk1UU1Qk1UU1Qk11oSFD_vq�ROV�Q59^tt^2[OV�Q5o
U
O2U
O	2PPP2Ja	P!)%fhJv9h)r:�strc�*:�ROU]2!r9�r���argr5s&�r�<lambda>�0ThreadTests.test_args_argument.<locals>.<lambda>�s���4�#3�#3�C��#;r c�*:�ROU]2!r9r�r�s&�rr�r��s���D�$4�$4�S�!�$<r c�*:�ROUQ2!�r�r�r�s&�rr�r��s���4�#3�#3�C��#?r c�*:�ROUQ2!r�r�r�s&�rr�r��s���D�$4�$4�S�%�$@r c�,:�ROU],2!r9r�r�s&�rr�r��s����(8�(8��q�c�(Br c�*:�ROUQ2!)r:r9r�r�s&�rr�r��s����(8�(8��d�(Cr �r��argsr9r�)�subTestr)rR�start�join)r5�num_list�	num_tuple�str_list�	str_tuple�
list_in_tuple�
tuple_in_list�
test_casesr�r��tsf          r�test_args_argument�ThreadTests.test_args_argument�s�����3���	��7���	����
���
��;�<�
�<�=�
�?�@�
�@�A�
�B�C�
�C�D�

�
�'�L�D����V��7�7��$�$�F�>�����	�����8�7�'�7�7�7�s�"8B(	�(B9
�1B9
c	��[O2UO[[O]2UO[[O]Q5UO[[O]]]]Q5P!)r:)�a)r��b)r)�Lock�assertRaises�	TypeErrorr4s&r�test_lock_no_args�ThreadTests.test_lock_no_args�sZ���������)�Y�^�^�Q�7����)�Y�^�^�q��9����)�Y�^�^�Q��Q�!��Dr c��UO[29^tt^2QQ[O2oPPP2P!)%fhP!9h)c��\sQs]�sQsP!)�1ThreadTests.test_lock_no_subclass.<locals>.MyLockrx�rErFrGrHrIrxr r�MyLockr��s��$r r�)r�r�r)r�)r5r�s& r�test_lock_no_subclass�!ThreadTests.test_lock_no_subclass�s0���
�
�y�
)�
)�.����.�*�
)�
)�
)�s�A�A	�A	c�r�]PHoUO[OP*UO2P!r0)�types�assertIsInstancer)r��	UnionType)r5r�s& r�test_lock_or_none�ThreadTests.test_lock_or_none�s"������i�n�n�t�3�U�_�_�Er c	�H�]
o[O]Q5o[O2o[2o,o[	U2FDno[QU*VV42oUO
U2UOUO2UO[U2Q2UO2Jp	[[Q2%cz[9PIc.QU2DjJ	LQU22[O2.*oUOPU2UO![#U2U]*2[$%c['Q2SFD�oUO)2UO+UO-22UO/UO]2UO1UO2UO[U2Q2J�	[$%c['Q2UO!UO32]2P!)	�
r2z<thread %d>z^<TestThread\(.*, initial\)>$�
get_native_idc3�D�SF �DpOw�	J	P!3hrB)�	native_id)�.0r�s& r�	<genexpr>�/ThreadTests.test_various_ops.<locals>.<genexpr>�s��'���'�Q�[�[�'�s� z!waiting for all tasks to completez#^<TestThread\(.*, stopped -?\d+\)>$zall tasks done)r)�BoundedSemaphore�RLockr.�rangerN�append�assertIsNone�ident�assertRegex�reprr��hasattr�setr��assertNotInr��lenrr[r��assertFalse�is_alive�assertNotEqual�assertIsNotNonerC)	r5�NUMTASKSrSrT�
numrunning�threads�ir��
native_idss	&        r�test_various_ops�ThreadTests.test_various_ops�s������)�)��2�����!���Y�
����x��A��=��?�D��J�A��N�N�1�����a�g�g�&����T�!�W�&F�G�
�G�G�I�!��9�o�.�.���:�'�:���:�'�:�:�i�>U�>U�>W�=X�X�J����T�:�.����S��_�h��l�;��7��5�6��A�
�F�F�H����Q�Z�Z�\�*��������+�� � ����)����T�!�W�&L�M���7��"�#�������)�1�-r c�``�UO[O2O2UU1Qko[O2n,n[
O29^tt^2[OUQ2oRO2UOR]*U2PPP2P!)%fhP!9h)c�:�RO[O2O2RO	2P!rB)r�r)�current_threadr�r�)rYr�s��r�f�9ThreadTests.test_ident_of_no_threading_threads.<locals>.f�s'����L�L��1�1�3�9�9�:��H�H�Jr rx)r�r)r�r��Eventr�wait_threads_exit�_thread�start_new_thread�waitr�)r5r��tidrYr�s&  @@r�"test_ident_of_no_threading_threads�.ThreadTests.test_ident_of_no_threading_threads�s�������Y�5�5�7�=�=�>�	���� ����
�
/�
/�
1�
1��*�*�1�b�1�C��I�I�K����U�1�X�s�+�2�
1�
1�
1�s�-AB8�8C		�C		c��[%c[Q2[OQ2UO2[O]2P![O
c[OQ2gh9h)z!with 256 KiB thread stack size...i�4platform does not support changing thread stack size�	rr[r)�
stack_sizer��errorr�SkipTestr�r4s&r�test_various_ops_small_stack�(ThreadTests.test_various_ops_small_stack�so���7��5�6�	H�� � ��(�	
�������Q���	�}�}�	H��#�#�F�H�
H�	H���A�B�,Bc��[%c[Q2[OQ2UO2[O]2P![O
c[OQ2gh9h)zwith 1 MiB thread stack size...ir�r�r4s&r�test_various_ops_large_stack�(ThreadTests.test_various_ops_large_stackso���7��3�4�	H�� � ��*�	
�������Q���	�}�}�	H��#�#�F�H�
H�	H�r�c��```�PnPnUUU1Qko[O2oUO2[O29^tt^2[
OV12oUO2PPP2RdRgROWRO2RO[29^tt^2RO2PPP2ROO2RO[29^tt^2RO2PPP2]o[O 2U*o[O 2U6cH[O"O%RO2RIcP![O&Q2JaRO)Q2P!)%fhCKK9h)%fhCK9h)%fhK�9h)Nc� :�[O2nROoROU[O2ROR[O2RO[OOU2R2RORO2Q2ROQ[R22UO2P![c
oSnPo=K$Po=hh9hSO2h9h)z-Expected _DummyThread to be considered alive.�_DummyThread)r)r�r��assertIn�_activer�r��assertIsrC�
assertTruer�r��
BaseException�release)rTr��e�dummy_threadr�r5s&  ���rr��*ThreadTests.test_foreign_thread.<locals>.fs����
 �
 )�7�7�9��"�(�(���
�
�c�9�#4�#4�5��%�%�l�I�4J�4J�K��
�
�i�/�/�3�3�C�8�,�G���� �)�)�+�C���
�
�n�d�<�.@�A��
�
���!�
����
���
�
��s0�CC!�!	C8�+C8�,C3�.C;�3C8�8C;�;D
皙�����?z[It was expected that the created threading._DummyThread was removed from threading._active.)r)r��acquirerr�r�r�r�r�r��RuntimeErrorr��_started�clearr�r]�	monotonicr�rCr^�fail)r5r�rTr��timeout�
timeout_atr�r�sf     @@r�test_foreign_thread�ThreadTests.test_foreign_threadsS�������	 �,��� ��
�
�
��
�
/�
/�
1�
1��*�*�1�h�7�C��M�M�O�2����K�����l�0�0�1�
�
�
�|�
,�
,�����-����#�#�%�
�
�
�|�
,�
,��!�!�#�-����^�^�%��/�
��n�n���+�� � �$�$�\�%7�%7�8��L���J�J�r�N��I�I�s�t�-2�
1�
1��-�
,�
,��-�
,�s6�(F=�G�G%�=G	�G	�G"	�G"	�%G5	�.G5	c�`	`
`�[Q2oUOOoUOUO1UmQQ[2n	UO	R	2o[O2oUOU[2UOU]2UVC2oJR	cLh9hSOW]2L[cLh9h[O2n[O2n
S	S
S1QkQ[O 2oS2oP	SmSO%2[&%c[)Q2[&%c[)Q2SPS2oSOS]2[&%c[)Q2RO+2oSO-S2[&%c[)Q2SO/SO02[&%c[)Q	2SSO2S2oSOS]2[&%c[)Q
2R
O+[4O6Q5SO-SO02[&%c[)Q2SO0%cSO92P!P!)
�ctypesc��\sQsQsQsP!)�<ThreadTests.test_PyThreadState_SetAsyncExc.<locals>.AsyncExc�Mrxr�rxr r�AsyncExcr
Ms��r rc�4:`�\sQsQsnUUU1QksQsUsP!)�:ThreadTests.test_PyThreadState_SetAsyncExc.<locals>.Worker�pc��:�[O2UmP
UmRO	2[
OQ2J)RcP	SmRO	2P!h9h)Fr�)r)�	get_ident�id�finishedr�r]r^)r5r�worker_saw_exception�worker_starteds&���rra�>ThreadTests.test_PyThreadState_SetAsyncExc.<locals>.Worker.runqs[���#�-�-�/��� %��
�/��&�*�*�,��
�
�3����/�$(�D�M�(�,�,�.�/�s�)A�A0�A0�/A0)rr�rErFrGrHrarIrJ)rLrrrs@���r�Workerrps����

/�

/r rz    started worker threadz     trying nonsensical thread idz,    waiting for worker thread to get startedz"    verifying worker hasn't exitedz2    attempting to raise asynch exception in workerz5    waiting for worker to say it caught the exception�rz    all OK -- joining worker)r�	pythonapi�PyThreadState_SetAsyncExc�c_ulong�	py_object�argtypes�	Exceptionr)rr��int�
assertGreaterrr��UnboundLocalErrorr�rR�daemonr�rr[r�r�r�rrr�
SHORT_TIMEOUTr�)r5r�
set_async_exc�	exceptionr��resultrr��retrrrs&        @@@r�test_PyThreadState_SetAsyncExc�*ThreadTests.test_PyThreadState_SetAsyncExcFs*����x�(���(�(�B�B�
�"(�.�.�&�2B�2B�!C�
��	�y�	��$�$�X�.�	��!�!�#�����c�3�'����3��"�	-�"�3�2�F�����	��	��	����V�Q�'�� �	��	��#���*��(���0��	/�	/�Y�%�%�	/�
�H�����	���	��7��-�.��7��4�5��r�9�-�������#��7��@�A��!�!�#��������7��6�7�������$��7��F�G��q�t�t�Y�/�������#��7��I�J��!�!�'�*?�*?�!�@�����
�
�#��7��0�1��:�:�:�
�F�F�H�s0�!B,�,B6�2B6�5B6�:C
�
	C�C�C�pthread_killzneed pthread_kill�SIGUSR1zneed SIGUSR1c�R```�[Q2o[O2nQQ[2nPnUUU1Qko[OUQ5oUO2RO
2[O[OQ2UOUOR2oUOU]2[O[O2FDLoUO2%fL4[O UO[O2JN	UO%2[O[O[O&2UO)RR2P!["cJgh9h)�_testlimitedcapic��\sQsQsQsQsP!)�VThreadTests.test_PyThreadState_SetAsyncExc_interrupts_sleep.<locals>.InjectedException�zCustom exception for testingrx)rErFrGrH�__doc__rIrxr r�InjectedExceptionr3�s��.r r6c�:�QoRO2[OU2P!RcoSnPo=P!Po=hh9h)�<i�Q)r�r]r^)�day_as_seconds�excr6�caught_exceptionrs  ���r�catch_exception�TThreadTests.test_PyThreadState_SetAsyncExc_interrupts_sleep.<locals>.catch_exception�s;���)�N�
'��"�"�$��
�
�>�*��$�
'�#&� ��
'�s�&.�A�A�=�Ar�c��P!rBrx)�sig�frames&&rr��MThreadTests.test_PyThreadState_SetAsyncExc_interrupts_sleep.<locals>.<lambda>�s��r )rr)r�r"rRr�r��signalr/�threadstate_set_async_excr�r�r�sleeping_retryr'r�r.�OSErrorr��SIG_DFLr�)	r5�	_testcapir<rr*�_r6r;rs	&     @@@r�/test_PyThreadState_SetAsyncExc_interrupts_sleep�;ThreadTests.test_PyThreadState_SetAsyncExc_interrupts_sleep�s*���"�"4�5�	�"���*��	/�	�	/� ��	'��!�!��9�����������
�
�f�n�n�&=�>��4�4��L�L�+�-�������#��'�'��(=�(=�>�A��?�?�$�$��
��#�#�F�L�L�&�.�.�A�	?�	���
��
�
�f�n�n�f�n�n�5����.�0A�B���
��
�s�/F�	F&�F&�%F&c�F�Qo[OoU[m[OQQ5oUO[OUO
2UO
U[O7Q2U[mP!S[mh9h)c�.�[O2grB)r)�ThreadError�r��kwargss*,r�fail_new_thread�7ThreadTests.test_limbo_cleanup.<locals>.fail_new_thread�s���'�'�)�)r c��P!rBrxrxr rr��0ThreadTests.test_limbo_cleanup.<locals>.<lambda>����r r�z:Failed to cleanup _limbo map on failure of Thread.start().)r)�_start_joinable_threadrRr�rMr�r��_limbo)r5rPrUr�s&   r�test_limbo_cleanup�ThreadTests.test_limbo_cleanup�s���	*�!*�!A�!A��+:�	�(�	F�� � ��5�A����i�3�3�Q�W�W�=�����Y�%�%�%�L�
N�0F�I�,��/E�I�,�s�A%B�
B c��[OP	Q5%cUOQ2[Q2[	QQ2vqoUOU]*2P!)Tr�TSAN would report thread leakr�-caNif 1:
            import ctypes, sys, time, _thread

            # This lock is used as a simple event variable.
            ready = _thread.allocate_lock()
            ready.acquire()

            # Module globals are cleared before __del__ is run
            # So we save the functions in class dict
            class C:
                ensure = ctypes.pythonapi.PyGILState_Ensure
                release = ctypes.pythonapi.PyGILState_Release
                def __del__(self):
                    state = self.ensure()
                    self.release(state)

            def waitingThread():
                x = C()
                ready.release()
                time.sleep(100)

            _thread.start_new_thread(waitingThread, ())
            ready.acquire()  # Be sure the other thread is waiting.
            sys.exit(42)
            )rr�skipTestrr
r��r5�rc�out�errs&   r�test_finalize_running_thread�(ThreadTests.test_finalize_running_thread�sS���"�"�$�/�/�
�M�M�9�:��h��,�T�4�����2	
����R� r c�|�[OP	Q5%cUOQ2[QQ2P!)TrrZr[aPif 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print('program blocked; aborting')
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            )rrr\r	r4s&r�test_finalize_with_trace�$ThreadTests.test_finalize_with_traces3���"�"�$�/�/�
�M�M�9�:��� �	r c��[QQ2vqoUOUO2Q2UOUQ2P!)r[a�if 1:
                import threading
                from time import sleep

                def child():
                    sleep(1)
                    # As a non-daemon thread we SHOULD wake up and nothing
                    # should be torn down yet
                    print("Woke up, sleep function is:", sleep)

                threading.Thread(target=child).start()
                raise SystemExit
            s5Woke up, sleep function is: <built-in function sleep>r �r	r��stripr]s&   r�test_join_nondaemon_on_shutdown�+ThreadTests.test_join_nondaemon_on_shutdown sE��(��/�����	
�������D�	F�����c�"r c	���[Oo[O2o[	]]d2FDyo[
OUQ*2[OQQ5oUO2UO2U2oUOVEQV51*2J{	[OU2P![OS2h9h)r:g-C��6*?c��P!rBrxrxr rr��7ThreadTests.test_enumerate_after_join.<locals>.<lambda><s��Dr r�z&#1703448 triggered after %d trials: %s)r)�	enumerater�getswitchintervalr�r�setswitchintervalrRr�r�r�)r5�enum�old_intervalr�r��ls&     r�test_enumerate_after_join�%ThreadTests.test_enumerate_after_join4s����"�"���,�,�.��
	0��1�c�]���)�)�!�f�*�5��$�$�L�9�����	������F��� � ��<��v�E�G�
#�
�!�!�,�/��C�!�!�,�/�s�B
C
�
C"��size�memuse�dry_runc�`�,nQoU1Qko[]]2FD�o[OUQ5,o[U2FD2oUO[OUU]*1Q52J4	SFDoUO	2J	[
OQ2SFDoUO2J	R%fJ�R]*g	P!)c�4�[OQ2P!)g{�G�zt?�r]r^rxr r�worker�;ThreadTests.test_join_from_multiple_threads.<locals>.workerJs���J�J�u�r c�:�UO2P![coROS2Po=P!Po=hh9hrB)r�r"r�)rr��errorss& �r�joiner�;ThreadTests.test_join_from_multiple_threads.<locals>.joinerMs0���
!����
���
!��
�
�a� � ��
!�s��	=�=�8�=r�r��{�G�z�?)r�r)rRr�r�r]r^r�)	r5rwr}r��Nr�r�r�r�s	&&      @r�test_join_from_multiple_threads�+ThreadTests.test_join_from_multiple_threadsEs������	�	!��q�"��A� �'�'�v�6�7�G��1�X�����y�/�/�v�6=�a�j�]� D�E�������	���J�J�t����������v��Q�i��r c�`�[O2nRO2U1Qko[OUQ5oUO2UO
QQ5RO2UO
2P!)c�*:�RO2P!rB)r��locks�rr}�2ThreadTests.test_join_with_timeout.<locals>.workerds����L�L�Nr r�r�r)r��
allocate_lockrr)rRr�r�r�)r5r}rr�s&  @r�test_join_with_timeout�"ThreadTests.test_join_with_timeout`sZ����$�$�&������	��!�!��0���������D��!��������
r c��QQ[2o[U2UP
Q5o[OU2oUOO2=UO
U2Q[OU22*Q5UP	Q5o[OU2oUOO2=UO
U2Q[OU22*Q5P!)c�.`�\sQsQsnQsQsQsUsP!)�DThreadTests.test_no_refcycle_through_target.<locals>.RunSelfFunction�pc��Vm[OUOU1QU-Q5UmUOO2P!)�yet_another)r�r�rO)�should_raiser)rR�_runrr�)r5r�s&&rr6�MThreadTests.test_no_refcycle_through_target.<locals>.RunSelfFunction.__init__qsB��%1�!�'�.�.�d�i�i�59�G�7D�T�6J�L������!�!�#r c�8�UO%c[gP!rB)r��
SystemExit)r5�	other_refr�s&&&rr��IThreadTests.test_no_refcycle_through_target.<locals>.RunSelfFunction._runzs���$�$�$�$�$�%r )r�r)rErFrGrHr6r�rIrJrKs@r�RunSelfFunctionr�ps����
$�
%�
%r r�)r�z%d references still around)�msg)	r�r,�weakref�refrr�r�r�getrefcount)r5r��
cyclic_object�weak_cyclic_object�raising_cyclic_object�weak_raising_cyclic_objects&     r�test_no_refcycle_through_target�+ThreadTests.test_no_refcycle_through_targetos���	%�f�	%�	#�4�(�'�U�;�
�$�[�[��7�����!�!�#�����,�.�:�!�o�o�.@�.B�C�D�	�	F�!0�T� B��%,�[�[�1F�%G�"��$�$�)�)�+�!����4�6�:�!�o�o�.H�.J�K�L�	�	Nr c�j�[O2oUO[Q29^tt^2UO	2PPP2UO[Q29^tt^2UOP	2PPP2UO[Q29^tt^2UO
2PPP2UO[Q29^tt^2UOQ2PPP2[O2oUO[Q29^tt^2UO2PPP2[O2oUO2UO[Q29^tt^2UO2PPP2UO[Q29^tt^2[O2PPP2UO[Q29^tt^2[O2PPP2P!)%fhCK�9h)%fhCK�9h)%fhCK�9h)%fhCKo9h)%fhCK79h)%fhK�9h)%fhK�9h)%fhP!9h)	zget the daemon attributezset the daemon attributezget the name attributezset the name attributerQzuse is_set()zuse notify_all()zuse active_count()zuse current_thread())r)rR�assertWarnsRegex�DeprecationWarning�isDaemon�	setDaemon�getName�setNamer��isSet�	Conditionr�	notifyAll�activeCount�
currentThread)r5r�r��conds&   r�test_old_threading_api�"ThreadTests.test_old_threading_api�s���
�����
�
"�
"�#5�#>�@�@�
�J�J�L�@��
"�
"�#5�#>�@�@�
�K�K���@��
"�
"�#5�#<�>�>�
�I�I�K�>��
"�
"�#5�#<�>�>�
�I�I�f��>�
�O�O���
�
"�
"�#5�~�
F�
F�
�G�G�I�G��"�"�$������
�
"�
"�#5�7I�
J�
J��N�N��K��
"�
"�#5�7K�
L�
L��!�!�#�M�
�
"�
"�#5�7M�
N�
N��#�#�%�O�
N�1@�@�@��@�@�@��>�>�>��>�>�>��
G�
F�
F��
K�
J��M�
L��
N�
N�
N�s��H�,H+�$H?�I�(I'�I;�;J�7J!�H(	� H(	�+H<	�4H<	�?I	�I	�I$	�I$	�'I8	�0I8	�;J	�J	�J	�J	�!J2	�*J2	c��[O2oUOQ[U22P	UmUOQ[U22P!�r&)r)rRr�r�r&r��r5r�s& r�test_repr_daemon�ThreadTests.test_repr_daemon�s=�����������4��7�+�����
�
�h��Q��(r c�0�[O2oUOUO2[OP
Q5oUOUO2[OP	Q5oUO	UO2P!)Fr�)r)rRr�r&r�r�s& r�test_daemon_param�ThreadTests.test_daemon_param�sd�������������"����E�*��������"����D�)��������!r c�r�Qo[QU2vq#oUOUQ2UOUQ2P!)a�if 1:
            import _thread, threading, os, time, warnings

            def background_thread(evt):
                # Creates and registers the _DummyThread instance
                threading.current_thread()
                evt.set()
                time.sleep(10)

            evt = threading.Event()
            _thread.start_new_thread(background_thread, (evt,))
            evt.wait()
            assert threading.active_count() == 2, threading.active_count()
            with warnings.catch_warnings(record=True) as ws:
                warnings.filterwarnings(
                        "always", category=DeprecationWarning)
                if os.fork() == 0:
                    assert threading.active_count() == 1, threading.active_count()
                    os._exit(0)
                else:
                    assert ws[0].category == DeprecationWarning, ws[0]
                    assert 'fork' in str(ws[0].message), ws[0]
                    os.wait()
        r[r �r	r��r5�coderHr_r`s&    r�test_dummy_thread_after_fork�(ThreadTests.test_dummy_thread_after_fork�s;����0'�t�T�2��������c�"�����c�"r c	��[O2oUO[OU2[O
OQ2[
]2FD�o[OQQ5oUO2[O[QQ59^tt^2[O29o]6Xc0[OUO!2%c]L]
2L(UO#2[
O$U]
Q5PPP2J�	P!)%fhJ�9h)g���ư>c��P!rBrxrxr rr��6ThreadTests.test_is_alive_after_fork.<locals>.<lambda>�rTr r��ignore��category�action��exitcode)rror'rprrr�r)rRr�rs�catch_warningsr��os�fork�_exitr�r��wait_process)r5rrr�r��pids&    r�test_is_alive_after_fork�$ThreadTests.test_is_alive_after_fork�s����,�,�.������-�-�|�<�	
���&�&�t�,��r��A�� � ��5�A�
�G�G�I��(�(�2D�08�:�:��7�7�9�$�C��*��H�H�1�:�:�<�<�R�R�8��F�F�H��(�(��r�:�:�:�	�:�:�:�s�1D3	�%D3	�41D3	�3E
�<E
c�`�[O2oROUOQ2ROUO[O
2O2ROUO[O22U1Qko[OUQ5oUO2UO2P!)�
MainThreadc�:�RO[O2O[O2O2P!rB)r�r)�main_threadr�r�r4s�rr��'ThreadTests.test_main_thread.<locals>.f�s5������	� 5� 5� 7� =� =� )� 8� 8� :� @� @�
Br r�)
r)r�r�rQr�r�rrRr�r�)r5�mainr��thsf   r�test_main_thread�ThreadTests.test_main_thread�s�����$�$�&��������L�1�������Y�%=�%=�%?�%E�%E�F�������Y�%8�%8�%:�;�	B��
�
�Q�
'��
���
�
���	r �waitpidztest needs os.waitpid()c��Qo[QU2vq#oUO2OQP2oUOUQ2UOUQ2P!)a!if 1:
            import os, threading
            from test import support

            ident = threading.get_ident()
            pid = os.fork()
            if pid == 0:
                print("current ident", threading.get_ident() == ident)
                main = threading.main_thread()
                print("main", main.name)
                print("main ident", main.ident == ident)
                print("current is main", threading.current_thread() is main)
            else:
                support.wait_process(pid, exitcode=0)
        r[�
r zHcurrent ident True
main MainThread
main ident True
current is main True
�r	�decode�replacer��r5r�rHr_r`�datas&     r�test_main_thread_after_fork�'ThreadTests.test_main_thread_after_forksX����'�t�T�2�����z�z�|�#�#�D�"�-������c�"�����2�	3r c���Qo[QU2vq#oUO2OQP2oUOUOQ2P2UOUQ2P!)a�if 1:
            import os, threading, sys, warnings
            from test import support

            def func():
                ident = threading.get_ident()
                with warnings.catch_warnings(record=True) as ws:
                    warnings.filterwarnings(
                            "always", category=DeprecationWarning)
                    pid = os.fork()
                    if pid == 0:
                        print("current ident", threading.get_ident() == ident)
                        main = threading.main_thread()
                        print("main", main.name, type(main).__name__)
                        print("main ident", main.ident == ident)
                        print("current is main", threading.current_thread() is main)
                        # stdout is fully buffered because not a tty,
                        # we have to flush before exit.
                        sys.stdout.flush()
                    else:
                        assert ws[0].category == DeprecationWarning, ws[0]
                        assert 'fork' in str(ws[0].message), ws[0]
                        support.wait_process(pid, exitcode=0)

            th = threading.Thread(target=func)
            th.start()
            th.join()
        r[r��utf-8zTcurrent ident True
main Thread-1 (func) Thread
main ident True
current is main True
r�r�s&     r�/test_main_thread_after_fork_from_nonmain_thread�;ThreadTests.test_main_thread_after_fork_from_nonmain_threadsa����8'�t�T�2�����z�z�|�#�#�D�"�-��������G�,�b�1�����2�	r c��QU*o[QQQU2vq4oUO2OQP2oUOUO2P2SOSU%cQLPQU8Q0*Q*2P!)	aCif 1:
            import os, threading, sys, traceback, _thread
            from test import support

            def func(lock):
                ident = threading.get_ident()
                if %s:
                    # call current_thread() before fork to allocate DummyThread
                    current = threading.current_thread()
                    print("current", current.name, type(current).__name__)
                print("ident in _active", ident in threading._active)
                # flush before fork, so child won't flush it again
                sys.stdout.flush()
                pid = os.fork()
                if pid == 0:
                    print("current ident", threading.get_ident() == ident)
                    main = threading.main_thread()
                    print("main", main.name, type(main).__name__)
                    print("main ident", main.ident == ident)
                    print("current is main", threading.current_thread() is main)
                    print("_dangling", [t.name for t in list(threading._dangling)])
                    # stdout is fully buffered because not a tty,
                    # we have to flush before exit.
                    sys.stdout.flush()
                    try:
                        threading._shutdown()
                        os._exit(0)
                    except:
                        traceback.print_exc()
                        sys.stderr.flush()
                        os._exit(1)
                else:
                    try:
                        support.wait_process(pid, exitcode=0)
                    except Exception:
                        # avoid 'could not acquire lock for
                        # <_io.BufferedWriter name='<stderr>'> at interpreter shutdown,'
                        traceback.print_exc()
                        sys.stderr.flush()
                    finally:
                        lock.release()

            join_lock = _thread.allocate_lock()
            join_lock.acquire()
            th = _thread.start_new_thread(func, (join_lock,))
            join_lock.acquire()
        z-Wzignore::DeprecationWarningr[r�zcurrent Dummy-1 _DummyThread
zident in _active �
zmcurrent ident True
main MainThread _MainThread
main ident True
current is main True
_dangling ['MainThread']
r�)r5�create_dummyr�rHr_r`r�s&&     r�/test_main_thread_after_fork_from_foreign_thread�;ThreadTests.test_main_thread_after_fork_from_foreign_threadEs���.�\�].��b'�t�-I�4�QU�V�����z�z�|�#�#�D�"�-���������r�*�����>J�:�PR�,�\�,<�B�?�@�6�6�	7r c�,�UOP	Q5P!)T)r�)r�)r5r�s&&r�-test_main_thread_after_fork_from_dummy_thread�9ThreadTests.test_main_thread_after_fork_from_dummy_thread�s���<�<�$�<�Or c��Qo[QU2vq#oUO2oUOUQ2UOUO2Q,]*2P!)a�if 1:
            import gc, threading

            main_thread = threading.current_thread()
            assert main_thread is threading.main_thread()  # sanity check

            class RefCycle:
                def __init__(self):
                    self.cycle = self

                def __del__(self):
                    print("GC:",
                          threading.current_thread() is main_thread,
                          threading.main_thread() is main_thread,
                          threading.enumerate() == [main_thread])

            RefCycle()
            gc.collect()  # sanity check
            x = RefCycle()
        r[r zGC: True True True)r	r�r��
splitlinesr�s&     r� test_main_thread_during_shutdown�,ThreadTests.test_main_thread_during_shutdown�sX����('�t�T�2�����z�z�|������c�"�������*�.�/�!�3�	5r c�N�Qo[QU2vq#oUOUQ2P!)a�if 1:
            import os
            import threading
            import time
            import random

            def random_sleep():
                seconds = random.random() * 0.010
                time.sleep(seconds)

            class Sleeper:
                def __del__(self):
                    random_sleep()

            tls = threading.local()

            def f():
                # Sleep a bit so that the thread is still running when
                # Py_Finalize() is called.
                random_sleep()
                tls.x = Sleeper()
                random_sleep()

            threading.Thread(target=f).start()
            random_sleep()
        r[r r��r5r�r^r_r`s&    r�test_finalization_shutdown�&ThreadTests.test_finalization_shutdown�s+����4(��d�3��������c�"r c�D``�[O2n[O2nRO2RO2UU1Qko[OUQ5oUO2RO2UO
Q[U22RO2Qo[Q2FD,oU[U27cL[OQ2J.	UO
U[U22UO2P!)c�J:�RO2RO2P!rB)r�r)�finish�starteds��rr��(ThreadTests.test_repr_stopped.<locals>.f�s����O�O���N�N�r r�r��stopped��r�)
r�r�rr)rRr�r�r�r�r�r]r^r�)r5r�r��LOOKING_FORr�r�r�s&    @@r�test_repr_stopped�ThreadTests.test_repr_stopped�s�����'�'�)���&�&�(����������	�
���A�&��	���	������
�
�i��a��)����� ���s��A��d�1�g�%���J�J�t���	
�
�
�k�4��7�+�	���r c
�l�[]]
2FCDo[OU2o[U2Tt,tFD$o[OUOQ5MJ&	ooSFDoUO2J	SFDoUO
2J	[U2Tt,tFD$o[OUOQ5MJ&	ooSFDoUO2J	SFDoUO
2J	UO[UO2CJ	P!ttohttoh)r:r�)
r�r)r�rRrr�r�r�r��
ValueError)r5�limit�bsrHr�r�s&     r�test_BoundedSemaphore_limit�'ThreadTests.test_BoundedSemaphore_limit�s����1�b�\�\�E��+�+�E�2�B� %�e��.� ,�1�!�'�'�r�z�z�:� ,�
�.������	���������!&�e��.� ,�1�!�'�'�r�z�z�:� ,�
�.������	������������j�"�*�*�5�"��.��.s�,D,�#,D1c��```�[Q2oU1QknQnUU1QknPRm[O2o[OR2[
OR2UO
R2[]2FD
oR2J	[OU2[
OU2P![OS2[
OS2h9h)rGc�
:�R!rBrx�r@�eventr��
noop_traces&&&�rr�9ThreadTests.test_frame_tstate_tracing.<locals>.noop_trace��	����r c3� �Qw�	J3h)r:�	generatorrxrxr rr�8ThreadTests.test_frame_tstate_tracing.<locals>.generators����!�!�s�
c�d:�ROe
R2Rm[RO2!rB)�gen�next)�callbackrs��rr�7ThreadTests.test_frame_tstate_tracing.<locals>.callbacks%����|�|�#�(�{�������%�%r )rrr�gettrace�settracer)�call_in_temporary_c_threadr�)r5rG�	old_tracerrrrs&   @@@r�test_frame_tstate_tracing�%ThreadTests.test_frame_tstate_tracing�s����!�+�.�	�	�	"�	&�����L�L�N�	����Z� �	*����z�*�
�0�0��:��a����
�!�
�L�L��#����y�)��
�L�L��#����y�)�s
�AC�.C0c�`�U1Qkn[O2o[OR2[O2oUORU2[OU2P![OS2h9h)c�
:�R!rBrxrs&&&�rr�-ThreadTests.test_gettrace.<locals>.noop_tracerr )r)rrr�)r5r�
trace_funcrs&  @r�
test_gettrace�ThreadTests.test_gettracesf���	��&�&�(�	�	*����z�*�"�+�+�-�J����Z�
�3����y�)��I���y�)�s�=A4�4Bc�4```�Qo[O2o[O2n[O2n,nUUU1Qko[OUQ5oUO	2RO2[OU2RO2UO2UORPU,2UO[O2U2UO[O2U2[OU2UO[O2U2UO[O2U2P![OS2h9h)c��P!rBrx�r�s*r�fn�1ThreadTests.test_gettrace_all_threads.<locals>.fn+���tr c��:�RO[O22RO2RO	2RO[O22P!rB)r�rrr�r�)�first_check�second_check�trace_funcss���r�checker�6ThreadTests.test_gettrace_all_threads.<locals>.checker1sA������s�|�|�~�.��O�O���������s�|�|�~�.r r�)r)rr�rRr�r��settrace_all_threadsr�r�r�r)r5r*rr1r�r.r/r0s&    @@@r�test_gettrace_all_threads�%ThreadTests.test_gettrace_all_threads*s�����&�&�(�	��o�o�'�� ���(����	/�	6�� � ��0�A�
�G�G�I������*�*�2�.�����
�F�F�H����[�4��*�5����Y�/�/�1�2�6����S�\�\�^�R�0��*�*�9�5�����+�+�-�y�9���������3��
�*�*�9�5��
�CE?�?Fc��Qo[O2o[OU2UOU[O22[OU2P![OS2h9h)c��P!rBrxr)s*rr*�'ThreadTests.test_getprofile.<locals>.fnHr,r )r)�
getprofile�
setprofiler�)r5r*�old_profiles&  r�test_getprofile�ThreadTests.test_getprofileGs\����*�*�,��	.�� � ��$����R��!5�!5�!7�8�� � ��-��I� � ��-�s�;A.�.Bc�4```�Qo[O2o[O2n[O2n,nUUU1Qko[OUQ5oUO	2RO2[OU2RO2UO2UORPU,2UO[O2U2UO[O2U2[OU2UO[O2U2UO[O2U2P![OS2h9h)c��P!rBrxr)s*rr*�3ThreadTests.test_getprofile_all_threads.<locals>.fnQr,r c��:�RO[O22RO2RO	2RO[O22P!rB)r�rr:r�r�)r.�
profile_funcsr/s���rr1�8ThreadTests.test_getprofile_all_threads.<locals>.checkerWsC���� � ����!1�2��O�O������� � ����!1�2r r�)r)r:r�rRr�r��setprofile_all_threadsr�r�r�r)r5r*r<r1r�r.rCr/s&    @@@r�test_getprofile_all_threads�'ThreadTests.test_getprofile_all_threadsPs�����*�*�,���o�o�'�� ���(���
�	3�	:�� � ��0�A�
�G�G�I������,�,�R�0�����
�F�F�H����]�T�2�J�7����Y�1�1�3�R�8����S�^�^�-�r�2��,�,�[�9�����-�-�/��=�������)�;�7��
�,�,�[�9�r6c�f�[QQ2vqoUOUO2Q2P!)r[a(if 1:
            import threading

            class Atexit:
                def __del__(self):
                    print("thread_dict.atexit = %r" % thread_dict.atexit)

            thread_dict = threading.local()
            thread_dict.atexit = "value"

            atexit = Atexit()
        sthread_dict.atexit = 'value')r	r��rstripr]s&   r�test_locals_at_exit�ThreadTests.test_locals_at_exitms2��(��/�
����	
�������'F�Gr c���QQ[2oU2o[OUQ5oUO2UO	2UOUO2P!)c�4`�\sQsQsnQsQsQsQsUsP!)�6ThreadTests.test_boolean_target.<locals>.BooleanTargeti�c��P
UmP!�F��ranr4s&rr6�?ThreadTests.test_boolean_target.<locals>.BooleanTarget.__init__�s	�� ��r c��P
!rPrxr4s&r�__bool__�?ThreadTests.test_boolean_target.<locals>.BooleanTarget.__bool__�s��r c��P	UmP!)TrQr4s&r�__call__�?ThreadTests.test_boolean_target.<locals>.BooleanTarget.__call__�s	����r rQ)	rErFrGrHr6rUrXrIrJrKs@r�
BooleanTargetrN�s����
!�
�
 �
 r rZr�)r�r)rRr�r�r�rR)r5rZr�rs&   r�test_boolean_target�ThreadTests.test_boolean_target~sI��
	 �F�	 �����!�!��0���������
�����
�
�#r c���Qo[O29^tt^2[OUQ5O	2PPP2P!)%fhP!9h)c��P!rBrxrxr r�noop�0ThreadTests.test_leak_without_join.<locals>.noop�r{r r�)rr�r)rRr�)r5r_s& r�test_leak_without_join�"ThreadTests.test_leak_without_join�s<��	�
�
/�
/�
1�
1����D�)�/�/�1�2�
1�
1�
1�s�&A�A#	�A#	c��[OQ2o[QU2vq#oUOUQ2UOUQ2P!)a�
            import _thread
            import sys

            event = _thread.allocate_lock()
            event.acquire()

            def import_threading():
                import threading
                event.release()

            if 'threading' in sys.modules:
                raise Exception('threading is already imported')

            _thread.start_new_thread(import_threading, ())

            # wait until the threading module is imported
            event.acquire()
            event.release()

            if 'threading' not in sys.modules:
                raise Exception('threading is not imported')

            # don't wait until the thread completes
        r[r )�textwrap�dedentr	r�r�s&    r�test_import_from_another_thread�+ThreadTests.test_import_from_another_thread�sI����� �
��2(��d�3��������c�"�����c�"r c��Qo[QU2vq#oUOUO2Q2UOQU2P!)a6if 1:
            import _thread

            def f():
                print("shouldn't be printed")

            class AtFinalization:
                def __del__(self):
                    print("OK")
                    _thread.start_new_thread(f, ())
            at_finalization = AtFinalization()
        r[�OKs/can't create new thread at interpreter shutdown)r	r�rhr�r�s&    r�%test_start_new_thread_at_finalization�1ThreadTests.test_start_new_thread_at_finalization�s@����'�t�T�2�����������e�,��
�
�H�#�Nr c	�$�QFDsoUOUQ59^tt^2[OQUQ02o[QU2vq4oUO	UQ2UOQU2PPP2Ju	P!)%fhJ�9h)Nrag
                    import threading


                    def loop():
                        while True:
                            pass


                    class Cycle:
                        def __init__(self):
                            self.self_ref = self
                            self.thr = threading.Thread(
                                target=loop, daemon=True)
                            self.thr.start()

                        def __del__(self):
                            assert self.thr.is_alive()
                            try:
                                self.thr.join(timeout=a�)
                            except PythonFinalizationError:
                                assert self.thr.is_alive()
                                print('got the correct exception!')

                    # Cycle holds a reference to itself, which ensures it is
                    # cleaned up during the GC that runs after daemon threads
                    # have been forced to exit during finalization.
                    Cycle()
                r[r �got the correct exception)Nr�)r�rdrer	r�r�)r5rr�r^r_r`s&     r�'test_join_daemon_thread_in_finalization�3ThreadTests.test_join_daemon_thread_in_finalization�s���"�G����g��.�.����,7�&8?�i�	@�'(���: 0��d�;����� � ��c�*��
�
�:�C�@�A/�.�"�.�.�.�s�AA>	�>B
�B
c��[OQ2o[QU2vq#oUOUQ2UO	QU2P!)a�
            import threading
            done = threading.Event()

            def set_event():
                done.set()

            class Cycle:
                def __init__(self):
                    self.self_ref = self
                    self.thr = threading.Thread(target=set_event, daemon=True)
                    self.thr.start()
                    self.thr.join()

                def __del__(self):
                    assert done.is_set()
                    assert not self.thr.is_alive()
                    self.thr.join()
                    assert not self.thr.is_alive()
                    print('all clear!')

            Cycle()
        r[r s	all clear�rdrer	r�r�r�s&    r�0test_join_finished_daemon_thread_in_finalization�<ThreadTests.test_join_finished_daemon_thread_in_finalization�sG����� �
��.(��d�3��������c�"��
�
�l�C�(r �lock_class_namer�r�c��[OQUQU8QUQU8Q0	2o[QU2vq4oUOUQ2UO	QU2P!)z�
            import threading
            import time

            thread_started_event = threading.Event()

            lock = threading.z.()
            def loop():
                if z� == 'RLock':
                    lock.acquire()
                with lock:
                    thread_started_event.set()
                    while True:
                        time.sleep(1)

            uncontested_lock = threading.a�()

            class Cycle:
                def __init__(self):
                    self.self_ref = self
                    self.thr = threading.Thread(
                        target=loop, daemon=True)
                    self.thr.start()
                    thread_started_event.wait()

                def __del__(self):
                    assert self.thr.is_alive()

                    # We *can* acquire an unlocked lock
                    uncontested_lock.acquire()
                    if a; == 'RLock':
                        uncontested_lock.acquire()

                    # Acquiring a locked one fails
                    try:
                        lock.acquire()
                    except PythonFinalizationError:
                        assert self.thr.is_alive()
                        print('got the correct exception!')

            # Cycle holds a reference to itself, which ensures it is
            # cleaned up during the GC that runs after daemon threads
            # have been forced to exit during finalization.
            Cycle()
        r[r rmrq)r5rtr�r^r_r`s&&    r�/test_acquire_daemon_thread_lock_in_finalization�;ThreadTests.test_acquire_daemon_thread_lock_in_finalizations������$�.�.�/�#�&�'*�+:�):�;�(�*�+	�=, �,
��Z(��d�3��������c�"��
�
�2�C�8r c�(�]QHGoGoQo[QQU2vqVoUO
2oQU7cUO	Q2UOUQ2UOUQ2P![coSO	S2Po=K�Po=hh9h)	r1)�	setrlimit�RLIMIT_NPROCaif 1:
            import resource
            import _thread

            def f():
                print("shouldn't be printed")

            limits = resource.getrlimit(resource.RLIMIT_NPROC)
            [_, hard] = limits
            resource.setrlimit(resource.RLIMIT_NPROC, (0, hard))

            try:
                handle = _thread.start_joinable_thread(f)
            except RuntimeError:
                print('ok')
            else:
                print('!skip!')
                handle.join()
        z-ur[s!skip!z.RLIMIT_NPROC had no effect; probably superusersokr )�resourceryrz�ImportErrorr\r	rhr�)r5ryrzr`r�rHr_s&      r�test_start_new_thread_failed�(ThreadTests.test_start_new_thread_failedIs���
	�8���&'�t�T�4�8�����i�i�k������M�M�J�K�����e�$�����c�"��5�	��M�M�#����	�s�A+�+	B�5B�6B�Bc�L�[OQ2o[QU2P!)a�
            import os
            import sys
            import threading
            import time
            import _testcapi

            lock = threading.Lock()
            lock.acquire()
            thread_started_event = threading.Event()
            def thread_func():
                try:
                    thread_started_event.set()
                    _testcapi.finalize_thread_hang(lock.acquire)
                finally:
                    # Control must not reach here.
                    os._exit(2)

            t = threading.Thread(target=thread_func)
            t.daemon = True
            t.start()
            thread_started_event.wait()
            # Sleep to ensure daemon thread is blocked on `lock.acquire`
            #
            # Note: This test is designed so that in the unlikely case that
            # `0.1` seconds is not sufficient time for the thread to become
            # blocked on `lock.acquire`, the test will still pass, it just
            # won't be properly testing the thread behavior during
            # finalization.
            time.sleep(0.1)

            def run_during_finalization():
                # Wake up daemon thread
                lock.release()
                # Sleep to give the daemon thread time to crash if it is going
                # to.
                #
                # Note: If due to an exceptionally slow execution this delay is
                # insufficient, the test will still pass but will simply be
                # ineffective as a test.
                time.sleep(0.1)
                # If control reaches here, the test succeeded.
                os._exit(0)

            # Replace sys.stderr.flush as a way to run code during finalization
            orig_flush = sys.stderr.flush
            def do_flush(*args, **kwargs):
                orig_flush(*args, **kwargs)
                if not sys.is_finalizing:
                    return
                sys.stderr.flush = orig_flush
                run_during_finalization()

            sys.stderr.flush = do_flush

            # If the follow exit code is retained, `run_during_finalization`
            # did not run.
            sys.exit(1)
        r[)rdrer	�r5�scripts& r� test_finalize_daemon_thread_hang�,ThreadTests.test_finalize_daemon_thread_hangls$�����:"�:
��v	��v�&r r�z$test needs threading.get_native_id()c�$�Qo[QU2vq#oUOU]2UOUQ2UO2O2oUO[	U2]2UOU]*U]*2P!)aBif True:
            import threading
            import os
            from test import support

            parent_thread_native_id = threading.current_thread().native_id
            print(parent_thread_native_id, flush=True)
            assert parent_thread_native_id == threading.get_native_id()
            childpid = os.fork()
            if childpid == 0:
                print(threading.current_thread().native_id, flush=True)
                assert threading.current_thread().native_id == threading.get_native_id()
            else:
                try:
                    assert parent_thread_native_id == threading.current_thread().native_id
                    assert parent_thread_native_id == threading.get_native_id()
                finally:
                    support.wait_process(childpid, exitcode=0)
            r[r )r	r�rhr�r�r�)r5r�r^r_r`r�s&     r�test_native_id_after_fork�%ThreadTests.test_native_id_after_fork�s{����&(��f�5��������Q������c�"��Y�Y�[�+�+�-�
�����Z��!�,����J�q�M�:�a�=�9r c��Qo[QU2vq#oUOU]2UOUQ2UOUO2Q2P!)aif True:
            import gc
            import sys
            import threading
            NUM_THREADS = 5
            b = threading.Barrier(NUM_THREADS + 1)
            def run_in_bg():
                b.wait()
                while True:
                    sys.setprofile(None)
                    gc.collect()

            for _ in range(NUM_THREADS):
                t = threading.Thread(target=run_in_bg, daemon=True)
                t.start()

            b.wait()
            print("Exiting...")
        r[r s
Exiting...rg�r5r�r^r_r`s&    r�'test_stop_the_world_during_finalization�3ThreadTests.test_stop_the_world_during_finalization�sQ����&(��f�5��������Q������c�"��������m�4r rxi�rP)FrErFrGrH�maxDiffrrtr�r�r�r�r�r�r�r�r�rr,r�
skipUnlessr�rBrIrWrardrirtr�
bigmemtestr�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�rr
rr%r4r=rFrJr[rarfrjrnrr�subTestsrvr}r�r)r�r�rIrJrKs@rrprpxs������G��D��D��=��=�4�6E�/�F�".�H,�	 �	 �2u�l�U��U�p�
������8�:M�N�
������3�^�D�*C�E�O��*C�X
F�#!�J�<#�(0�"
���R��%�@� �A� �4
%�N�B&�>)�"��#��#�>�;��;�,��
�����Y�/�1J�K�3�L��3�2�
�����Y�/�1J�K�%�L��%�N�
�����Y�/�1J�K�<7�L��<7�|P�5�:!#�F�66�$�&*��&*�P
*�4�:.�8�:H�"$�&2�#�BO�"'A�R)�<
���'�&�'�):�;�49�<�49�l!#�F�='��='�~�
�����O�<�>d�e�:�f��:�65�5r rpc��`�\sQsQsnQsQs\Q2s\Q2s\	O\O\
7Q2\O](Q
P
Q5Q22sQ	s\Q
2s\Q2sQsUsP!)�ThreadJoinOnShutdowni�c��QU*o[QU2vq#oUO2OQP2oUOUQ2P!)a�if 1:
            import sys, os, time, threading

            # a thread, which waits for the main program to terminate
            def joiningfunc(mainthread):
                mainthread.join()
                print('end of thread')
                # stdout is fully buffered because not a tty, we have to flush
                # before exit.
                sys.stdout.flush()
        
r[r�zend of main
end of thread
r�)r5r�r^r_r`r�s&&    r�
_run_and_join�"ThreadJoinOnShutdown._run_and_join�sN��
��
��(��f�5�����z�z�|�#�#�D�"�-������=�>r c�.�QoUOU2P!)z�if 1:
            import os
            t = threading.Thread(target=joiningfunc,
                                 args=(threading.current_thread(),))
            t.start()
            time.sleep(0.1)
            print('end of main')
            �r�r�s& r�test_1_join_on_shutdown�,ThreadJoinOnShutdown.test_1_join_on_shutdown�s����	
���6�"r c�.�QoUOU2P!)a�if 1:
            from test import support

            childpid = os.fork()
            if childpid != 0:
                # parent process
                support.wait_process(childpid, exitcode=0)
                sys.exit(0)

            # child process
            t = threading.Thread(target=joiningfunc,
                                 args=(threading.current_thread(),))
            t.start()
            print('end of main')
            r�r�s& r�test_2_join_in_forked_process�2ThreadJoinOnShutdown.test_2_join_in_forked_processs����	
���6�"r c�.�QoUOU2P!)a�if 1:
            from test import support

            main_thread = threading.current_thread()
            def worker():
                childpid = os.fork()
                if childpid != 0:
                    # parent process
                    support.wait_process(childpid, exitcode=0)
                    sys.exit(0)

                # child process
                t = threading.Thread(target=joiningfunc,
                                     args=(main_thread,))
                print('end of main')
                t.start()
                t.join() # Should not block: main_thread is already stopped

            w = threading.Thread(target=worker)
            w.start()
            r�r�s& r�!test_3_join_in_forked_from_thread�6ThreadJoinOnShutdown.test_3_join_in_forked_from_threads��
��*	
���6�"r zdue to known OS bugrvc��[OP	Q5%cUOQ2Qo[QU2vq4oUO	U2P!)TrrZa�if True:
            import os
            import random
            import sys
            import time
            import threading

            thread_has_run = set()

            def random_io():
                '''Loop for a while sleeping random tiny amounts and doing some I/O.'''
                import test.test_threading as mod
                while True:
                    with open(mod.__file__, 'rb') as in_f:
                        stuff = in_f.read(200)
                        with open(os.devnull, 'wb') as null_f:
                            null_f.write(stuff)
                            time.sleep(random.random() / 1995)
                    thread_has_run.add(threading.current_thread())

            def main():
                count = 0
                for _ in range(40):
                    new_thread = threading.Thread(target=random_io)
                    new_thread.daemon = True
                    new_thread.start()
                    count += 1
                while len(thread_has_run) < count:
                    time.sleep(0.001)
                # Trigger process shutdown
                sys.exit(0)

            main()
            r[)rrr\r	r�)r5rwr�r^r_r`s&&    r�test_4_daemon_threads�*ThreadJoinOnShutdown.test_4_daemon_threads3sL���"�"�$�/�/�
�M�M�9�:�!��D(��f�5��������r c��Qo[QU2vq#oUOUQ2UOUO2Q2UOU]2P!)a�if True:
            import threading
            import time

            def thread2():
                time.sleep(0.05)
                print("OK")

            def thread1():
                time.sleep(0.05)
                t2 = threading.Thread(target=thread2)
                t2.start()

            t = threading.Thread(target=thread1)
            t.start()
            # do not join() -- the interpreter waits for non-daemon threads to
            # finish.
            r[r rirgr�s&    r�test_thread_from_thread�,ThreadJoinOnShutdown.test_thread_from_threadcsQ����$(��f�5��������c�"��������e�,�����Q�r c�^�Qo[O[QQ59^tt^2,o[]2FD;o[O
UQ5oUO
U2UO2J=	SFDoUO2J	PPP2P!)%fhP!9h)c��[O2oU]6�c[OU]2Q5P![O]22P!)r1r�)r�r�rr�r�)r�s r�do_fork_and_wait�IThreadJoinOnShutdown.test_reinit_tls_after_fork.<locals>.do_fork_and_wait�s/���'�'�)�C��Q�w��$�$�S�2�6�����r r�r�r�)	rsr�r�r�r)rRr�r�r�)r5r�r�r�r�s&    r�test_reinit_tls_after_fork�/ThreadJoinOnShutdown.test_reinit_tls_after_fork{s���
	��
$�
$�.@�,4�6�6��G��2�Y���$�$�,<�=�����q�!����	��
�������6�6�6�6�s�A(B�B,	�$B,	c��,o[]2FD<o[OQQ5oUOU2UO	2J>	[
O[QQ59^tt^2[O2oU]6XcR[[O22]6Xc[O]32L/[O]42L[OU]3Q5PPP2SFDoUO!2J	P!)%fhK,9hSFDoSO!2J	h9h)�c�0�[OQ2!)g333333�?r|rxr rr��KThreadJoinOnShutdown.test_clear_threads_states_after_fork.<locals>.<lambda>�s�����C�r r�r�r�r�)r�r)rRr�r�rsr�r�r�r�r�r�_current_framesr�rr�r�)r5r�r�r�r�s&    r�$test_clear_threads_states_after_fork�9ThreadJoinOnShutdown.test_clear_threads_states_after_fork�s���
���r��A�� � �(@�A�A��N�N�1��
�G�G�I��
	��(�(�2D�08�:�:��g�g�i���!�8��3�.�.�0�1�Q�6������������(�(��r�:�:��������:�:���������s7�$D2�5D�"D�5AD�;D2�D/	�(D/	�*D2�2Erxi`)rErFrGrHr�r�rr�r�rr"rrrrr�r�r�r�r�rIrJrKs@rr�r��s�����?�"
#��#��#�&�#��#�6�_�_�S�\�\�%6�6�8M�N����R��%�@�,�A�O�,�\ �0����2���r r�c�`�\sQsQsnQsQsQs\Q2s\	\
OP	P	Q5Q22sQQP	Q	P	Q
P
-Qkks
\	Q2s\	Q
2sQsUsP!)�SubinterpThreadingTestsi�c��[O2vqUO[OU2UO[OU2[	[Q2%c[O
UP
2V1!)�set_blocking)r��piper'�closer�r�)r5�r�ws&  rr��SubinterpThreadingTests.pipe�sU���w�w�y���������!�$�������!�$��2�~�&�&��O�O�A�u�%��v�
r c��UO2vq[OQU1*2o[OOU2oUO
U]2UO
[OU]2Q2P!)a�
            import os
            import random
            import threading
            import time

            def random_sleep():
                seconds = random.random() * 0.010
                time.sleep(seconds)

            def f():
                # Sleep a bit so that the thread is still running when
                # Py_EndInterpreter is called.
                random_sleep()
                os.write(%d, b"x")

            threading.Thread(target=f).start()
            random_sleep()
        �x�	r�rdrerr�run_in_subinterpr�r��read�r5r�r�r�r+s&    r�test_threads_join�)SubinterpThreadingTests.test_threads_join�sp���y�y�{������ �$�d�% ���&�l�l�+�+�D�1������a� ��������A���-r c��UO2vq[OQU1*2o[OOU2oUO
U]2UO
[OU]2Q2P!)a�
            import os
            import random
            import threading
            import time

            def random_sleep():
                seconds = random.random() * 0.010
                time.sleep(seconds)

            class Sleeper:
                def __del__(self):
                    random_sleep()

            tls = threading.local()

            def f():
                # Sleep a bit so that the thread is still running when
                # Py_EndInterpreter is called.
                random_sleep()
                tls.x = Sleeper()
                os.write(%d, b"x")

            threading.Thread(target=f).start()
            random_sleep()
        r�r�r�s&    r�test_threads_join_2�+SubinterpThreadingTests.test_threads_join_2�sp��
�y�y�{������ �2�d�3 ���4�l�l�+�+�D�1������a� ��������A���-r c��UO2vqQoQoQo[O2oUOQUQU8QUQU8QUQU8Q0
2UO	2UO[OU]2U2UO[OU]2U2UO[OU]2U2P!)�I�F�Dz�if True:
            import os
            import threading
            import time

            done = False

            def notify_fini():
                global done
                done = True
                os.write(z, z�)
                t.join()
            threading._register_atexit(notify_fini)

            def task():
                while not done:
                    time.sleep(0.1)
                os.write(z\)
            t = threading.Thread(target=task)
            t.start()

            os.write(�)
            )r�r�create�execr�r�r�r�)r5�r_interp�w_interp�INTERP�FINI�DONE�interps&      r�test_threads_join_with_no_main�6SubinterpThreadingTests.test_threads_join_with_no_main�s���!�Y�Y�[����������$�$�&�����
�#��2�d�X�.�#��2�d�X�.��Z�r�&��,
�+�	�.	�����������1�-�v�6��������1�-�t�4��������1�-�t�4r )r�memoryc��[Q2Q[OOQ0oQU8Q0o[	QU2P!)rGz�if 1:
            import os
            import threading
            import time

            def f():
                # Make sure the daemon thread is still running when
                # Py_EndInterpreter is called.
                time.sleep(zJ)
            threading.Thread(target=f, daemon=True).start()
            zKif 1:
            import _testcapi

            _testcapi.run_in_subinterp(r�r[)rrrr'r	)r5�subinterp_coder�s&  r�test_daemon_threads_fatal_error�7SubinterpThreadingTests.test_daemon_threads_fatal_error"sG��	�k�"��!�L�L�6�6�7�8
�
��"�	$��
	��v�&r �allowed�daemon_allowedr&c��[Q2[OQUQUQ02o[[O
2o[OQU8QUQUQUQ0	2o[OO29^tt^2[Q	U2vq�PPP2U	O2!)%fhW	O2!9h)
�_testinternalcapiz�
            import test.support
            import threading
            def func():
                print('this should not have run!')
            t = threading.Thread(target=func, daemon=r�z#
            t.start()
            zh
            import test.support
            test.support.run_in_subinterp_with_config(
                z�,
                use_main_obmalloc=True,
                allow_fork=True,
                allow_exec=True,
                allow_threads=z',
                allow_daemon_threads=z0,
                check_multi_interp_extensions=z;,
                own_gil=False,
            )
            r[)
rrdre�boolr�Py_GIL_DISABLEDr�SuppressCrashReportr	r�)
r5�before_startr�r�r&r��check_multi_interp_extensionsr�rHr`s
&&$$$     r�_check_allowed�&SubinterpThreadingTests._check_allowed8s���
	�)�*�!���.6�
7=�X�>
�
�N�
�
*���)-�W�-D�-D�(E�%����&� �"�#� '�i�(&�&4�%5�6/�/L�.M�N
�"����\�\�
-�
-�
/�
/�(��v�6�I�A�q�0��z�z�|��0�
/��z�z�|��s�
B5�5C	�>C	c�T�UOP
P
P
Q5oUOQU2P!)F�r�r�r&r)r�r��r5r`s& r�test_threads_not_allowed�0SubinterpThreadingTests.test_threads_not_allowedYs0���!�!�� ��"�
��
	
�
�
�n�c�*r c	�x�UOQ29^tt^2UOP	P
P	Q5oUOQU2PPP2UOQ29^tt^2UOQP	P
P
Q5oUOQU2PPP2P!)%fhK[9h)%fhP!9h)zvia Thread()r�rzvia Thread.daemon setterzt.daemon = True)r�r�r�r�s& r�test_daemon_threads_not_allowed�7SubinterpThreadingTests.test_daemon_threads_not_allowedbs���
�\�\�.�
)�
)��%�%��$��&��C�

�M�M�.�#�.�
*��\�\�4�
5�
5��%�%�!��$��	&��C�
�M�M�.�#�.�6�
5�*�
)��6�
5�
5�s#�'B�#(B(�B%	�B%	�(B9	�1B9	rx)�)rErFrGrHr�r�r�r$r�rr�skip_if_sanitizerr�r�r�r�rIrJrKs@rr�r��s������.�8#.�J�#5��#5�J����d�4�8�'�9��'�(�#��&*��$��B�+��+��/��/r r�c��`�\sQsQsnQsQsQsQsQs\	2Q2s
QsQ	sQ
s
QsQsQ
sQs\	2\O&\O*Q6HQ2Q22sQsUsP!)�ThreadingExceptionTestsivc��[O2oUO2UO[UO2UO2P!rB)r)rRr�r�rr��r5rs& r�test_start_thread_again�/ThreadingExceptionTests.test_start_thread_againys6���!�!�#���������,����5����
r c�r�[O2oUO[UO2P!rB)r)r�r�rr�)r5r�s& r�test_joining_current_thread�3ThreadingExceptionTests.test_joining_current_threads&��"�1�1�3�����,��(;�(;�<r c�r�[O2oUO[UO2P!rB)r)rRr�rr�r�s& r�test_joining_inactive_thread�4ThreadingExceptionTests.test_joining_inactive_thread�s$���!�!�#�����,����4r c��[O2oUO2UO[[
UQP	2UO
2P!r�)r)rRr�r�rr(r�r�s& r�test_daemonize_active_thread�4ThreadingExceptionTests.test_daemonize_active_thread�s8���!�!�#���������,����4�H����
r c�r�[O2oUO[UO2P!rB)r)r�r�rr��r5r�s& r�test_releasing_unacquired_lock�6ThreadingExceptionTests.test_releasing_unacquired_lock�s"���~�~������,����5r c��QoQo[O[OQU,[O[OQ5oUO2vqEUO
2OQP2oUOUO]QUO
2*2UOVb2P!)aif True:
            import threading

            def recurse():
                return recurse()

            def outer():
                try:
                    recurse()
                except RecursionError:
                    pass

            w = threading.Thread(target=outer)
            w.start()
            w.join()
            print('end of main thread')
            zend of main thread
r[)�stdout�stderrr�zUnexpected error: )
�
subprocess�Popenr�
executable�PIPE�communicater�r�r��
returncode)r5r��expected_output�prrr�s&      r�test_recursion_limit�,ThreadingExceptionTests.test_recursion_limit�s�����"1�����c�n�n�d�F�;�$.�O�O�J�O�O�
M���������}�}��&�&�t�R�0��������q�*>�����*P�Q�����/r c��Qo[QU2vq#oUOUQ2UO2oUOQU2UOQU2UOQU2UO	QU2P!)a�if True:
            import threading
            import time

            running = False
            def run():
                global running
                running = True
                while running:
                    time.sleep(0.01)
                1/0
            t = threading.Thread(target=run)
            t.start()
            while not running:
                time.sleep(0.01)
            running = False
            t.join()
            r[r �Exception in thread�"Traceback (most recent call last):�ZeroDivisionError�Unhandled exception�r	r�r�r�r�r�s&    r�test_print_exception�,ThreadingExceptionTests.test_print_exception�st����$(��f�5��������c�"��j�j�l���
�
�+�S�1��
�
�:�C�@��
�
�)�3�/����.��4r c��Qo[QU2vq#oUOUQ2UO2oUOQU2UOQU2UOQU2UO	QU2P!)a�if True:
            import sys
            import threading
            import time

            running = False
            def run():
                global running
                running = True
                while running:
                    time.sleep(0.01)
                1/0
            t = threading.Thread(target=run)
            t.start()
            while not running:
                time.sleep(0.01)
            sys.stderr = None
            running = False
            t.join()
            r[r rrrrrr�s&    r�%test_print_exception_stderr_is_none_1�=ThreadingExceptionTests.test_print_exception_stderr_is_none_1�st����((��f�5��������c�"��j�j�l���
�
�+�S�1��
�
�:�C�@��
�
�)�3�/����.��4r c��Qo[QU2vq#oUOUQ2UOQUO22P!)a�if True:
            import sys
            import threading
            import time

            running = False
            def run():
                global running
                running = True
                while running:
                    time.sleep(0.01)
                1/0
            sys.stderr = None
            t = threading.Thread(target=run)
            t.start()
            while not running:
                time.sleep(0.01)
            running = False
            t.join()
            r[r r)r	r�r�r�r�s&    r�%test_print_exception_stderr_is_none_2�=ThreadingExceptionTests.test_print_exception_stderr_is_none_2�sB����((��f�5��������c�"����.��
�
��=r c�$�Qo[QU2P!)a9if True:
            import time
            import threading
            import _thread

            def f():
                try:
                    f()
                except RecursionError:
                    f()

            def g():
                try:
                    raise ValueError()
                except* ValueError:
                    f()

            def h():
                time.sleep(1)
                _thread.interrupt_main()

            t = threading.Thread(target=h)
            t.start()
            g()
            t.join()
            r[)r
r�s& r�test_print_exception_gh_102056�6ThreadingExceptionTests.test_print_exception_gh_102056s����6	�d�F�+r c�`�QnU1QkQ[O2oU2oUO2UO2UO	UO
2UO
UO
[2PUmP!)c��grBrxrxr r�
bare_raise�OThreadingExceptionTests.test_bare_raise_in_brand_new_thread.<locals>.bare_raise"s��r c�4:`�\sQsQsnPsU1QksQsUsP!)�OThreadingExceptionTests.test_bare_raise_in_brand_new_thread.<locals>.Issue27558i%c�X:�R2P![coXmPo=P!Po=hh9hrB)r"r:)r5r:r!s& �rra�SThreadingExceptionTests.test_bare_raise_in_brand_new_thread.<locals>.Issue27558.run(s$���#��L�� �#�"�H�H��#�s�
�	)�)�$�))r:)rErFrGrHr:rarIrJ)rLr!s@�r�
Issue27558r$%s�����C�
#�
#r r')r)rRr�r�r�r:r�r)r5r'rr!s&  @r�#test_bare_raise_in_brand_new_thread�;ThreadingExceptionTests.test_bare_raise_in_brand_new_thread!sb���	�	#��)�)�	#�����������
����V�Z�Z�(����f�j�j�,�7���
r c�(�QoUO[O[O2[	]d2Tt,tFDo[
OUQ5MJ	ooSFD#oUO2UO2J%	P!ttoh)c���[[OQQQ59^tt^2oUOQ2[O
2PPP2P!)%fhP!9h)r�r�)�encoding� )�openr�TESTFN�write�	traceback�format_stack)�fps r�modify_file�QThreadingExceptionTests.test_multithread_modify_file_noerror.<locals>.modify_file8s?���i�&�&��g�>�>�"�����
��&�&�(�?�>�>�>�s�'A�A(	� A(	r�)	r'r�unlinkr/r�r)rRr�r�)r5r4r�r�r�s&    r�$test_multithread_modify_file_noerror�<ThreadingExceptionTests.test_multithread_modify_file_noerror6sw��	)�
	
���	�(�(�)�*:�*:�;��3�Z�
���
���K�0��	�
��A�
�G�G�I�
�F�F�H���	
s�"Bc��Qo[QU2vq#oUOU]2UOUQ2UOUQ2P!)z�if True:
        import sys
        import threading

        threading.x = sys.modules[__name__]
        x = threading._DummyThread()
        r[r r�r�s&    r�)test_dummy_thread_on_interpreter_shutdown�AThreadingExceptionTests.test_dummy_thread_on_interpreter_shutdownFsK��
��(��d�3��������Q������c�"�����c�"r �ntz"signals don't work well on windowsc��]PHoQo[QV!OQ59^tt^2oUOUOO]2Q2UO
[O2UOO2UOO2oUOQU2PPP2P!)%fhP!9h)r1z�
        from threading import Thread
        import time
        import os


        def test():
            print('a', flush=True, end='')
            time.sleep(10)


        for _ in range(3):
            Thread(target=test).start()
        r[)rsaaasKeyboardInterrupt)rrrr�rr��send_signalrB�SIGINTr�flushr�)r5r�source�procr�s&    r�1test_keyboard_interrupt_during_threading_shutdown�IThreadingExceptionTests.test_keyboard_interrupt_during_threading_shutdownWs���	�
	���$����
?�
?�4����T�[�[�-�-�a�0�&�9����V�]�]�+��K�K�����K�K�$�$�&�E��M�M�.��6�@�
?�
?�
?�s�BC�C	�C	rx)rErFrGrHr�r�r�r�r�rrrrrrr(r7r:rr"r�rQrCrIrJrKs@rr�r�vs������>�5��6���0��0�>5�65�:>�2,�>�*� #�"��
�_�_�R�W�W��_�&J�K�7�L��7r r�c�(`�\sQsQsnQsQsUsP!)�
ThreadRunFailirc��[Q2g)�
run failed�rr4s&rra�ThreadRunFail.runss
����&�&r rxrrKs@rrFrFrs����'�'r rFc�``�\sQsQsnU1Qks\Q2s\O\Q22s	Qs
QsQsQs
Q	sUsU9s!)
�ExceptHookTestsiwc�<:�[U2[RU_	2P!rB)r,�superrh)r5�	__class__s&�rrh�ExceptHookTests.setUpxs���"�4�(�
��
�r c��[OQ29^tt^2o[QQ5oUO2UO	2PPP2WO2O
2oUOQWOQ0U2UOQU2UOQU2UOQU2P!)%fhK�9h)r�excepthook threadrP�Exception in thread �:
�#Traceback (most recent call last):
z   raise ValueError("run failed")zValueError: run failed)	r�captured_outputrFr�r��getvaluerhr�rQ)r5rrs&  r�test_excepthook�ExceptHookTests.test_excepthook|s���
�
$�
$�X�
.�
.�&�"�(;�<�F��L�L�N��K�K�M�/�
���"�(�(�*���
�
�,�V�[�[�M��=�v�F��
�
�<�f�E��
�
�8�&�A��
�
�.��7�/�
.�s�-C�C	�C	c�\�[OQ29^tt^2o[Q2g[cXo[O
,[O2NPM2o[OS2PoPo=LPoh9hPo=hh9hPPP2L)%fhL9hWO2O2oSOQ[O2Q0S2SOQS2SOQS2SOQS2P!)r�bugrSrTrUz  raise ValueError("bug")zValueError: bug)
rrVrr"r)�ExceptHookArgsr�exc_infor&rWrhr�r)r5rr:r�s&   r�test_excepthook_thread_None�+ExceptHookTests.test_excepthook_thread_None�s���
�
$�
$�X�
.�
.�&�
 � ��'�'���
 � �/�/�0G�#�,�,�.�0G�$�0G�H�� ��(�(��.� �D��4�D��

 ���/�
.�
.�
.�����"�(�(�*���
�
�,�Y�-@�-@�-B�,C�3�G��P��
�
�<�f�E��
�
�1�6�:��
�
�'��0sN�B�-�	B�B�-B
�&B�<B
�>B�B	�B
�
B�B�B,	�%B,	c�<�QQ[O2o[OQ29^tt^2oU2oUO	2UO2PPP2UO
WO2P2P!)%fhK29h)c�(`�\sQsQsnQsQsUsP!)�4ExceptHookTests.test_system_exit.<locals>.ThreadExiti�c�4�[O]2P!r9)r�exitr4s&rra�8ExceptHookTests.test_system_exit.<locals>.ThreadExit.run�s
������r rxrrKs@r�
ThreadExitrb�s����
�
r rfr)r)rRrrVr�r�r�rW)r5rfrrs&   r�test_system_exit� ExceptHookTests.test_system_exit�si��	��)�)�	�
�
$�
$�X�
.�
.�&��\�F��L�L�N��K�K�M�/�
	
������*�B�/�/�
.�s�(B�B	�B	c�$`�PnU1Qko[O[QU29^tt^2[2oUO	2UO2PPP2UO
RO[2UO
[RO2Q2UO
ROROO2UOROW2PnP!)%fhK�9hPnh9h)Nc�:�UnP!rBrx)�	hook_argsr�s&�r�hook�4ExceptHookTests.test_custom_excepthook.<locals>.hook�s����Dr r&rH)r�	swap_attrr)rFr�r�r��exc_typerr��	exc_value�
exc_traceback�
__traceback__r�r)r5rlrr�s&  @r�test_custom_excepthook�&ExceptHookTests.test_custom_excepthook�s������	�	��"�"�9�l�D�A�A�&����������
�B�

���T�]�]�J�7����S����0�,�?����T�/�/����1M�1M�N��M�M�$�+�+�v�.��D�B�A���D�s)�$D�+C8�BD�8D	�D	�D�Dc�L`�QoPnU1Qko[O[QU29^tt^2[O[QU29^tt^2[OQ29^tt^2o[2oUO
2UO2PPP2PPP2PPP2UOWO2Q2UORQ2P!)%fhKT9h)%fhK_9h)%fhKj9h)c��[Q2g)�threading_hook failedrIr)s&r�threading_hook�CExceptHookTests.test_custom_excepthook_fail.<locals>.threading_hook�s���4�5�5r c� :�[U2nP!rBr�)rorprq�err_strs&&&�r�sys_hook�=ExceptHookTests.test_custom_excepthook_fail.<locals>.sys_hook�s����)�n�Gr r&rz#Exception in threading.excepthook:
rw)
rrnr)rrVrFr�r�r�rW)r5rxr|rrr{s&    @r�test_custom_excepthook_fail�+ExceptHookTests.test_custom_excepthook_fail�s����	6���	%��
�
�y�,��
G�
G�
�
�
�s�L�(�
;�
;�
�
$�
$�X�
.�
.�&�"�_�F��L�L�N��K�K�M�/�<�H�	
������*�?�	A�����"9�:�/�
.��<�
;��H�
G�sM�%D�D	�6+C-
�!D	�)D�-C=�6C=�8D	�D
�	D
�D�D#	�D#	c�\�QoQoU2o[O[QU29^tt^2U2o[O[mU2oPPP2UOUW2UO
UW2UOUQ2P!)%fhKH9h)c��[OQ29^tt^2o[QQ5oUO2UO	2PPP2UO2!)%fhWO2!9h)rrRrP)rrVrFr�r�rW)�outputrs  r�
run_thread�<ExceptHookTests.test_original_excepthook.<locals>.run_thread�s^���(�(��2�2�f�&�,?�@���������
�3��?�?�$�$�	3�2��?�?�$�$�s�-A%�%B	�.B	c�>�[Q[OQ5P!)zRunning a thread failed)�file)r[rrr)s&rrx�@ExceptHookTests.test_original_excepthook.<locals>.threading_hook�s���+�#�*�*�=r r&zRunning a thread failed
)rrnr)r*r&r�r�)r5r�rx�default_output�custom_hook_output�recovered_outputs&     r�test_original_excepthook�(ExceptHookTests.test_original_excepthook�s���	%�	>�$���
�
�
�y�,��
G�
G�!+���#,�#;�#;�I� �)�|��H�
	
����)9�:����N�,>�?����+�-H�I�H�
G�s�(B�B+	�$B+	rx)rErFrGrHrhrrXrrr^rgrsr~r�rIrJ�
__classcell__�rOrLs@@rrLrLws[������
8��
8�
����1���1�(0��*;�*J�Jr rLc�4`�\sQsQsnQsQsQsQsUsP!)�
TimerTestsi�c�t�[OU2,Um[O2UmP!rB)rdrh�
callback_argsr)r��callback_eventr4s&rrh�TimerTests.setUp�s'�����4� ����'�o�o�/��r c��[OQUO2oUO2UOO2UOOQ2QUOQ$UOO2[OQUO2oUO2UOO2UO[UO2]2UOUOQ-1Q-1,2UO2UO2P!)r��blah�bar�foorx)r)�Timer�
_callback_spyr�r�r�r�r�rOrr�r�r�r�)r5�timer1�timer2s&  r� test_init_immutable_default_args�+TimerTests.test_init_immutable_default_args�s�������t�'9�'9�:��������� � �"������6�"�$��
�
�e�����!�!�#�����t�'9�'9�:��������� � �"�����T�/�/�0�!�4�����+�+�r�2�h��R��-A�B����
����
r c��UOOUQ*UO212UOO	2P!):NNN)r�r��copyr�r�)r5r�rOs&*,rr��TimerTests._callback_spy	s7�����!�!�4��7�F�K�K�M�":�;������!r )r�r�)	rErFrGrHrhr�r�rIrJrKs@rr�r��s����0�
�""�"r r�c�<�\sQsQs\\O2sQsP!)�	LockTestsi	rx)	rErFrGrH�staticmethodr)r��locktyperIrxr rr�r�	s���I�N�N�+�Hr r�c�<�\sQsQs\\O2sQsP!)�PyRLockTestsi	rx)	rErFrGrHr�r)�_PyRLockr�rIrxr rr�r�	s���I�.�.�/�Hr r�zRLock not implemented in Cc�L`�\sQsQsn\\O2sQsQs	Us
P!)�CRLockTestsi	c	��[OP	Q59^tt^2o[O2PPP2UO	W,2Q-1QQ]-1Q	Q]-1,oSFDRvq4UOV4Q59^tt^2UO[[O,UN3-U@PPP2JT	QQUO2o[OP	Q59^tt^2oU]]Q5PPP2UO	U,2P!)%fhK�9h)%fhJ�9h)%fhKK9h)
T)�recordr�rNc�@``�\sQsQsnU1QkU1QkksQsUsU9s!)�/CRLockTests.test_signature.<locals>.CustomRLocki!	c� :�U]6�cPgQP-!)��returnrx)�formatrLs"�r�__annotate__�ECRLockTests.test_signature.<locals>.CustomRLock.__init__.__annotate__"	s���
#�
#�4�
#r c�&:�[RU_2P!rB)rNr6)r5r�r�rOs&&$�rr6�8CRLockTests.test_signature.<locals>.CustomRLock.__init__"	s����� �"r rx)rErFrGrHr6rIrJr�r�s@@r�CustomRLockr�!	s����
#�
#�
#r r�)r�r9rx)r:r�)	rsr�r)r�r�r�r�r�r�)r5�warnings_log�	arg_typesr�rOr�s&     r�test_signature�CRLockTests.test_signature	s��
�
$�
$�D�
1�
1�\��O�O��2�����r�*��2�J�
�#�q��N�
�c�1�X��
�	�
&�L�D����4��7�7��!�!�)�Y�_�_�N�t�N�v�N�8�7�&�
	#�$�-�-�	#��
$�
$�D�
1�
1�\���Q��2�����r�*�)2�
1��8�7�7��2�
1�s5�D�+D'	�-D;�D$	�D$	�'D8
�0D8
�;E	�E	rx)rErFrGrHr�r)�_CRLockr�r�rIrJrKs@rr�r�	s�����I�-�-�.�H�+�+r r�c�<�\sQsQs\\O2sQsP!)�
EventTestsi)	rx)	rErFrGrHr�r)r��	eventtyperIrxr rr�r�)	s���Y�_�_�-�Ir r�c�R`�\sQsQsn\\O2sQsQs	Qs
UsP!)�ConditionAsRLockTestsi,	c�*�UOQ2P!)z%Condition allows positional arguments�r\r4s&r�test_constructor_noargs�-ConditionAsRLockTests.test_constructor_noargs0	s���
�
�=�>r c�*�UOQ2P!)z,Condition does not expose _recursion_count()r�r4s&r�test_recursion_count�*ConditionAsRLockTests.test_recursion_count3	s���
�
�D�Er rx)rErFrGrHr�r)r�r�r�r�rIrJrKs@rr�r�,	s&�����I�/�/�0�H�?�F�Fr r�c�<�\sQsQs\\O2sQsP!)�ConditionTestsi6	rx)	rErFrGrHr�r)r��condtyperIrxr rr�r�6	s���I�/�/�0�Hr r�c�<�\sQsQs\\O2sQsP!)�SemaphoreTestsi9	rx)	rErFrGrHr�r)�	Semaphore�semtyperIrxr rr�r�9	s���9�.�.�/�Gr r�c�<�\sQsQs\\O2sQsP!)�BoundedSemaphoreTestsi<	rx)	rErFrGrHr�r)r�r�rIrxr rr�r�<	s���9�5�5�6�Gr r�c�<�\sQsQs\\O2sQsP!)�BarrierTestsi?	rx)	rErFrGrHr�r)�Barrier�barriertyperIrxr rr�r�?	s���y�0�0�1�Kr r�c�^`�\sQsQsnQsQsQsQsQsQs	Qs
Q	sQ
sQs
QsUsP!)
�ThreadingIteratorToolsTestsiE	c	��`	`
`�Qo]
o]n	[O2n
[O2nQoU	U
U1Qko[OUU22o[	U2Tt,tFDo[O
VE1Q5MJ	oo[O29^tt^2SFDoUO2J	SFD)oUOdJ[OQ2J(	RO2SFDoUO2J	PPP2UOR	V]*
*]*2P!ttoh)%fhK=9h)i'c3�@ �[U2FDoUw�	J
	P!3hrB�r��r�xs& r�producer�\ThreadingIteratorToolsTests.test_serialize_serializes_concurrent_iteration.<locals>.producerM	�����5�\����"���c�:�RO2]oSFDoV*
oJ
	R9^tt^2RU*
nPPP2P!)%fhP!9hr0)r�)�iterator�totalr�r*�result_lockr�s&  ���r�consumer�\ThreadingIteratorToolsTests.test_serialize_serializes_concurrent_iteration.<locals>.consumerQ	s<����J�J�L��E����
������%�������s�
A�A	�A	r�r�)r)r�r��serialize_iteratorr�rRrr�r�r�r]r^r�r�r�)r5r�
workers_countr�r�r�rH�workersr}r*r�r�s&        @@@r�.test_serialize_serializes_concurrent_iteration�JThreadingIteratorToolsTests.test_serialize_serializes_concurrent_iterationF	s������
����n�n�&�����!��	�	 ��/�/����@���=�)�
�)��
���H�;�?�)�	�
��
/�
/�
1�
1�!������"�!���l�l�*��J�J�s�O�"�
�I�I�K�!�����
�"�2�	
�����!�)�!4��!9�:��
�2�
1�s�(#E�*,E�AE�E$	�E$	c���Qo[OU22oUO[U2Q2UOUO	Q2Q2UO[U2Q2UOUO[2Q2UO2UO[29^tt^2[U2PPP2P!)%fhP!9h)c3�\ �Qw�oQU0w�J[c
Qw�P!h9h3h)T�readyz	received �caughtrI)�vals r�echo�JThreadingIteratorToolsTests.test_serialize_generator_methods.<locals>.echon	s4���
�� '�-�C�%�c�U�+�+���
���
�s�,��	)�)�,�)�,r��hellozreceived hellor�)
r)r�r�r�send�throwrr�r��
StopIteration)r5r��its&  r� test_serialize_generator_methods�<ThreadingIteratorToolsTests.test_serialize_generator_methodsl	s���	��
)�
)�$�&�
1��	
����b��7�+�	
�������)�+;�<�����b��7�+�	
������*�-�x�8�	���
�
�
�
�}�
-�
-���H�.�
-�
-�
-�s�	C�C0	�(C0	c��[O,QN2oUO[29^tt^2UO	Q2PPP2UO[29^tt^2UO[2PPP2UO[29^tt^2UO2PPP2P!)%fhK�9h)%fhK[9h)%fhP!9h)r:r�)r:r��)r)r�r��AttributeErrorr�r�rr�)r5�standard_its& r�&test_serialize_methods_attribute_error�BThreadingIteratorToolsTests.test_serialize_methods_attribute_error�	s��� �2�2�9�=��
�
�
�~�
.�
.����U�#�/��
�
�~�
.�
.����j�)�/��
�
�~�
.�
.�����/�
.�
/�
.��/�
.��/�
.�
.�s5�C�.C�)C*�C	�
C	�C'	� C'	�*C;	�3C;	c���QQ2o[O,2oUUO2oV2mUO	]2UO[2UO2P!)c�@`�\sQsQsnQsQsQsQsQsQs	Us
P!)�cThreadingIteratorToolsTests.test_serialize_generator_methods_locking.<locals>.LockCheckingGeneratori�	c��VmP!rBr�r�s&&rr6�lThreadingIteratorToolsTests.test_serialize_generator_methods_locking.<locals>.LockCheckingGenerator.__init__�	s�� �	r c��U!rBrxr4s&r�__iter__�lThreadingIteratorToolsTests.test_serialize_generator_methods_locking.<locals>.LockCheckingGenerator.__iter__�	s���r c�^�UOO2%f[Q2gU!)zLock not held during send()�r��lockedr)r5r3s&&rr��hThreadingIteratorToolsTests.test_serialize_generator_methods_locking.<locals>.LockCheckingGenerator.send�	s&���y�y�'�'�)�)�&�'D�E�E��r c�^�UOO2%f[Q2gP!)zLock not held during throw()r	)r5r�s&*rr��iThreadingIteratorToolsTests.test_serialize_generator_methods_locking.<locals>.LockCheckingGenerator.throw�	�&���y�y�'�'�)�)�&�'E�F�F�*r c�^�UOO2%f[Q2gP!)zLock not held during close()r	r4s&rr��iThreadingIteratorToolsTests.test_serialize_generator_methods_locking.<locals>.LockCheckingGenerator.close�	rr r�)rErFrGrHr6rr�r�r�rIrJrKs@r�LockCheckingGeneratorr�	s&����
!�
�
�
G�
G�
Gr r)r)r��_lock�	_iteratorr�r�rr�)r5rr��mock_gens&   r�(test_serialize_generator_methods_locking�DThreadingIteratorToolsTests.test_serialize_generator_methods_locking�	sU��	G�	G�"�
)�
)�"�
-��(����2����	����
�
�����
���
r c���Qo[OU22oUO[29^tt^2[	U2PPP2P!)%fhP!9h)c3� �[g3hrB)rrxr rr��DThreadingIteratorToolsTests.test_serialize_next_exception.<locals>.f�	s�����s�
)r)r�r�rr)r5r��gs&  r�test_serialize_next_exception�9ThreadingIteratorToolsTests.test_serialize_next_exception�	sB��	�
�(�(���-��
�
�
�|�
,�
,���G�-�
,�
,�
,�s�A�A$	�A$	c	�``�]
o]o]dn[O2n[OQ2oUU1Qko[U2Tt,tFD	pS2MJ	ooVb*oSTt,tFDo[OVH1Q5MJ	o	o[
O29^tt^2S	FDo
U
O2J	RO2S	FDo
U
O2J	PPP2SOSTt.tFDo[U2jJ	toRU*.2P!ttohttoh)%fhKP9httoh)r�c3�^ �]oUw�	[OQ2U]*
oJ'3h)r1g����Mb@?r|)r�s r�atomic_counter�dThreadingIteratorToolsTests.test_synchronized_serializes_generator_instances.<locals>.atomic_counter�	s)����A�����
�
�6�"��Q���s�+-c�f:�RO2[R2FDo[U2J	P!rB)r�r�r)�counterrHrr�s& ��rr��^ThreadingIteratorToolsTests.test_synchronized_serializes_generator_instances.<locals>.consumer�	s!����J�J�L��5�\���W�
�"r r�)r)r��synchronized_iteratorr�rRrr�r�r�r�r�r)
r5�unique�repetitionsrr�rH�unique_counters�countersr"r�r}rr�s
&          @@r�0test_synchronized_serializes_generator_instances�LThreadingIteratorToolsTests.test_synchronized_serializes_generator_instances�	s������������!��	�	(�	(�	�
)�	�	�
6;�6�]�C�]��>�+�]��C�"�0��$�
�#��
���H�:�>�#�	�
��
/�
/�
1�
1�!������"��I�I�K�!�����
�"�	2�	
���*9�:�/�w�T�'�]�/�:�
�[�
 �!�	
��D��
�2�
1��
;s%�D+�&#D0�(AD5�E�5E	�>E	c��Qo[OU2oUOUOUO2UO	UO
U2UO[
U22],2P!)c3� �]w�	P!3hr9rxrxr rr�UThreadingIteratorToolsTests.test_synchronized_preserves_wrapped_metadata.<locals>.gen�	s
����G�s�	)r)r$r�rEr��__wrapped__�list)r5r�wrappeds&  r�,test_synchronized_preserves_wrapped_metadata�HThreadingIteratorToolsTests.test_synchronized_preserves_wrapped_metadata�	s_��	��1�1�#�6������)�)�3�<�<�8��
�
�g�)�)�3�/�����g�i��1�#�.r c�*`
```
`�Qo]o]n,n[O2n[O2n
[[	U22n
QoU
UUU
U1Qko[O
UU2UQ5oSTt,tFDo[OVF1Q5MJ	oo[O29^tt^2SFDoUO2J	R
O2SFDoUO2J	PPP2UOR,2UOR[U22SO[ST	t.tFDo	[U	O2jJ	to	2]2P!ttoh)%fhK�9htto	h)i�c3�@ �[U2FDoUw�	J
	P!3hrBr�r�s& rr��_ThreadingIteratorToolsTests.test_concurrent_tee_supports_concurrent_consumers.<locals>.producer�	r�r�c��:�RO2[U2oR9^tt^2UR6XcR]*
nLROUQ*2PPP2P!)%fhP!9h)r::N�N)r�r/r�)r��items�expected�failuresr�r��	successess& �����rr��_ThreadingIteratorToolsTests.test_concurrent_tee_supports_concurrent_consumers.<locals>.consumer�	sG����J�J�L���N�E����H�$���N�I��O�O�E�#�J�/�	����s�A�"A�A-	�%A-	��nr�)r)r�r�r/r��concurrent_teerRrr�r�r�r�r�r�rr�)r5r�num_threadsr�r��teesr�r�r}�t_objr9r:r�r�r;s&         @@@@@r�1test_concurrent_tee_supports_concurrent_consumers�MThreadingIteratorToolsTests.test_concurrent_tee_supports_concurrent_consumers�	s?��������	����n�n�&�����!����e��%��	�	0�	0��'�'����;�G��!�
� ��
���H�;�?� �	�
��
/�
/�
1�
1�!������"��I�I�K�!�����
�"�	2�	
����2�&�����C��I�.�	
����$�?�$��b����n�$�?�@�!�D��
�2�
1��@s�;#E8�=AE=�
 F�=F
	�F
	c�j�UO[O[]
2]Q5Q2P!)r�r=rx)r�r)r?r�r4s&r�"test_concurrent_tee_zero_iterators�>ThreadingIteratorToolsTests.test_concurrent_tee_zero_iterators
s#������1�1�%��)�q�A�2�Fr c��UO[29^tt^2[O[	]
2PQ5PPP2P!)%fhP!9h)r�r=)r�rr)r?r�r4s&r�test_concurrent_tee_negative_n�:ThreadingIteratorToolsTests.test_concurrent_tee_negative_n
s6��
�
�
�z�
*�
*��$�$�U�2�Y�"�5�+�
*�
*�
*�s�"A�A	�A	rx)rErFrGrHr�r�r�rrr)r1rCrFrIrIrJrKs@rr�r�E	sA����$;�L�6 ��<	�%
�N/�'E�RG�6�6r r�c�`�\sQsQsnQs\O\\Q2Q2\O\\Q2Q2Q22s	\O\\Q2Q2\O\\Q2Q2Q22s
Q	sUsP!)
�MiscTestCasei$
c�h�[U2Q.oQQ.o[OU[QVQ5P!)rMr�r�)�extra�not_exported)r)r�)r,r�check__all__r))r5rNrOs&  r�test__all__�MiscTestCase.test__all__%
s4��"�4�(����'��7�����T�9�.F�#(�	Er �set_namezmissing _thread.set_name�	_get_namezmissing _thread._get_namec�`
�UO[O[O22[	[QP2oS9%f]doQQQQU*QU]
**QU]*
*Q*QU]*
*Q*QU]*
*Q*QQU**QQU**Q	QU**Q
QU**,o[
O%c#UOQ[
O02[
O%c UO[
O2[OOQ2%cQ
oL[O2oU
1QkoSFCD	o[O%f�UOUQ2oQU7cUO!Q]2]*oUdUPUo[OOQ2%cUO#Q
Q2oL�[$O&U2oL|]o	,o
SFD@o[)U2Q6�cU	]*
o	L	U	]*
o	V�6�cLU
OU2JB	PO+U
2oQU7cUO!Q]2]*oUO-VhQQ59^tt^2[OU2UO/[O2U2PPP2UO-VhQQ59^tt^2Pn
[0O2VVQ5oUO52UO+2UO/R
UQ[7R
28Q[7U2802PPP2CJ	P!)%fhK�9h)%fhCJ59h)�_NAME_MAXLEN�
CustomNameunamé€z
embednullr�ué€u􏿿u🐍�xx�xxx�xxxxz	nonascii:�sunos�asciic�4:�[O2nP!rB)r�rT)�	work_names�r�work�(MiscTestCase.test_set_name.<locals>.work_
s����)�)�+�Ir r���surrogateescapei���r�)rQr9rr}rzlen(work_name)=z and len(expected)=u􏿿􏿿)r'r�rSrT�getattrr�FS_NONASCIIr��TESTFN_UNENCODABLErr�
startswith�getfilesystemencodingr�
MS_WINDOWS�encode�splitr�r��fsdecode�ordr�r�r�r)rRr�r�)r5�truncater�testsr,r_rQ�encodedr9rw�chars�chrr^s&            @r�
test_set_name�MiscTestCase.test_set_name-
s���	
����(�(�'�*;�*;�*=�>��7�N�D�9�����C��
�
�
�
�%�K�
�5�2�:��
�5�1�9���'�
�5�1�9���,��5�1�9�� 0�0��,��&�&��<�%�'�'��L�5�(�(��\�E�)�)�7
��:� � � ��L�L�9�Y�%:�%:�$;�<�=��'�'�'��L�L��5�5�6��<�<�"�"�7�+�+��H��0�0�2�H�	,��D��%�%�%��+�+�h�	�:���G�#�%�m�m�E�1�5�a�8�G��'�%�i�x�0�G��<�<�*�*�7�3�3�&�~�~�g�7H�I�H�!�{�{�7�3�H������B��2�w��'���	����	������L�L��$���7�7�5�>���8�#�'�~�~�d�A�6�q�9�H����4�6��J�J�� � ��&�� � ��!2�!2�!4�h�?�K����4�8��L�L� �	�"�)�)��A���������
�� � ��H�$3�C�	�N�#4�4H�#�h�-�9I�!J�L�M�L�?�6K�J��M�L�L�s%�<N0	�:A'O	�0O
�9O
�O
�O
c��``�PnPnUU1Qko[OUQQ5oUO2UO2UO	RQ2UO	RQ2P!)Nc�:�[O2nQ[O2m[O2nP!)�new name)r�rTr)r�rQ)�name1�name2s��rr_�+MiscTestCase.test_change_name.<locals>.work�
s0����%�%�'�E�.8�I�$�$�&�+��%�%�'�Er rQrrw)r)rRr�r�r�)r5r_rrxrys&  @@r�test_change_name�MiscTestCase.test_change_name�
sZ���
����	(��!�!��F�;���������
������'�����
�+r rx)
rErFrGrHrQrr�r�r�rsr{rIrJrKs@rrLrL$
s�����E������*�5�7Q�R�
�����+�6�8S�T�YL�U�S�YL�v�����*�5�7Q�R�
�����+�6�8S�T�,�U�S�,r rLc�`�\sQsQsnQsQs\Q2Q2sQsQs	Qs
Q	s\OQ
2sQsUsP!)�InterruptMainTestsi�
c��Qo[OV2oUO[OV2UO[29^tt^2[O
2PPP2P!)%fhP!9h)c��]]*P!r9rx)�signumr@s&&r�handler�LInterruptMainTests.check_interrupt_main_with_signal_handler.<locals>.handler�
s��
�a�C�Cr )rBr'r�rr��interrupt_main)r5r�r��old_handlers&&  r�(check_interrupt_main_with_signal_handler�;InterruptMainTests.check_interrupt_main_with_signal_handler�
sV��	��m�m�F�4������
�
�v�;�
�
�
�0�
1�
1��"�"�$�2�
1�
1�
1�s�A8�8B		�B		c��[OU2o[OU[O2[OU2[OU[O
2[OU2[OV2P![OX2h9hrB)rB�	getsignal�SIG_IGNr�r�rF)r5r�r�s&& r�check_interrupt_main_noerror�/InterruptMainTests.check_interrupt_main_noerror�
sr���"�"�6�*��		+��M�M�&�&�.�.�1��"�"�6�*��M�M�&�&�.�.�1��"�"�6�*�
�M�M�&�*��F�M�M�&�*�s�A6B'�'B?z*gh-118433: Flaky due to a longstanding bugc��Qo[OUQ5oUO[29^tt^2UO	2UO2PPP2UO2P!)%fhK"9h)c�2�[O2P!rB)r�r�rxr r�call_interrupt�HInterruptMainTests.test_interrupt_main_subthread.<locals>.call_interrupt�
s���"�"�$r r�)r)rRr��KeyboardInterruptr�r�)r5r�r�s&  r�test_interrupt_main_subthread�0InterruptMainTests.test_interrupt_main_subthread�
sT��	%����N�3��
�
�
�0�
1�
1�
�G�G�I�
�F�F�H�2�	
����2�
1�s�!A4�4B	�=B	c��UO[29^tt^2[O2PPP2P!)%fhP!9hrB)r�r�r�r�r4s&r�test_interrupt_main_mainthread�1InterruptMainTests.test_interrupt_main_mainthread�
s1���
�
�0�
1�
1��"�"�$�2�
1�
1�
1�s�?�A	�A	c��UO[O2UO[O2P!rB)r�rBr?�SIGTERMr4s&r�'test_interrupt_main_with_signal_handler�:InterruptMainTests.test_interrupt_main_with_signal_handler�
s&���5�5�f�m�m�D��5�5�f�n�n�Er c��UO[O2UO[O2P!rB)r�rBr?r�r4s&r�test_interrupt_main_noerror�.InterruptMainTests.test_interrupt_main_noerror�
s&���)�)�&�-�-�8��)�)�&�.�.�9r c��UO[[OP2UO[[O[O
2UO[[OQ2P!)r:i@B)r�rr�r�rB�NSIGr4s&r�"test_interrupt_main_invalid_signal�5InterruptMainTests.test_interrupt_main_invalid_signal�
sN�����*�g�&<�&<�b�A����*�g�&<�&<�f�k�k�J����*�g�&<�&<�g�Fr c���P	,oP
,oP
,oQo[OVBV1Q5oUO2U]*%fJP
U]$UO2UO	U]*2P!)Tc�j�QoP	U]$U]*%cU%cU]*oLP!J%P	U]$P!)i�rx)r��cont�interrupted�
iterationss&&& rr}�AInterruptMainTests.test_can_interrupt_tight_loops.<locals>.worker�
s4��$�J��G�A�J��q�'�'���!�O�J���!�K��Nr r�)r)rRr�r�r�)r5r�r�r�r}r�s&     r�test_can_interrupt_tight_loops�1InterruptMainTests.test_can_interrupt_tight_loops�
sj���v���'���g��		"�
���F�$�0L�M��	���	��!�*�*����Q��	��������A��'r rx)rErFrGrHr�r�rr�r�r�r�r�r�reap_threadsr�rIrJrKs@rr~r~�
sZ����%�+��F�G�	�H�	�%�F�:�G�
�"�"�(�#�(r r~c�>`�\sQsQsnQsQs\Q2sQsUs	P!)�AtexitTestsi�
c��[QQ2vqoUOU2UOUO2Q2P!)r[z�if True:
            import threading

            def run_last():
                print('parrot')

            threading._register_atexit(run_last)
        sparrot)r	r�r�rhr]s&   r�test_atexit_output�AtexitTests.test_atexit_output�
s=��'��/�
����	
������������i�0r c�H�[QQ2vqoUOU2P!)r[aNif True:
            import threading
            from unittest.mock import Mock

            mock = Mock()
            threading._register_atexit(mock)
            mock.assert_not_called()
            # force early shutdown to ensure it was called once
            threading._shutdown()
            mock.assert_called_once()
        )r	r�r]s&   r�test_atexit_called_once�#AtexitTests.test_atexit_called_once�
s'��'��
/�

����	
����r c��[QQ2vqoUOU2UOQUO22P!)r[z�if True:
            import threading

            def func():
                pass

            def run_last():
                threading._register_atexit(func)

            threading._register_atexit(run_last)
        z2RuntimeError: can't register atexit after shutdown)r	r�r�r�r]s&   r�test_atexit_after_shutdown�&AtexitTests.test_atexit_after_shutdown
s?��(��
/�

����	
������
�
�J��
�
��	r rx)
rErFrGrHr�r�rr�rIrJrKs@rr�r��
s#����1�
����r r��__main__)�netbsd5zhp-ux11)Hr5�test.supportrrrrrrr�test.support.import_helperrr�test.support.script_helperr	r
rrrZrr�r)r]rr�r�rrBrdr1rsr
rr�
concurrentrr|�requires_working_threadingrrr$r,r�r.rRrN�TestCaserdrpr�r�r�rFrLr�r��
RLockTestsr�r"r�r�r�r�r�r�r�r�r�rLr~r�rEr�rxr r�<module>r�si����T�T�9�9�I�\�\�,�
�
������	��
��������'��+�+�4�8�+��	�=�4��f��<��!�!�<�B%�8�$�$�%�j5�,�j5�X+K�<�K�\A/�l�A/�Hy7�l�y7�x'�I�$�$�'�
rJ�l�rJ�j"��"�8,�
�$�$�,�0�:�(�(�0�
����"�"�d�*�,H�I�+�*�'�'�+�J�+�4.��&�&�.�F�J�1�1�F�1�Z�.�.�1�0�Z�.�.�0�7�J�<�<�7�2�:�*�*�2�X6�,�X6�~w,�8�$�$�w,�tN(��*�*�N(�b0�(�#�#�0�f�z���M�M�O���EX���L��s�;I0�0I=�6I=�<I=

Youez - 2016 - github.com/yon3zu
LinuXploit