Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_concurrent_futures.cpython-39.pyc

a

��gp��@sddlmZe�d�e��ddlmZddlmZddlZddl	Z	ddl
Z
ddlmZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZddlmZdd	lmZmZmZmZmZmZmZdd
l m!Z!ddl"Z#ddl$Z#ddl#Z%ej&ddd��re�'d
��eddfdd�Z(e(ed�Z)e(ed�Z*e(ed�Z+e(ed�Z,e(ee-�d�Z.e(edd�Z/da0dd�Z1dd�Z2dd�Z3dd�Z4dd�Z5dd �Z6dkd!d"�Z7Gd#d$�d$e8�Z9Gd%d&�d&�Z:d'd(�Z;Gd)d*�d*ej<�Z=Gd+d,�d,�Z>Gd-d.�d.e>�Z?Gd/d0�d0e>�Z@Gd1d2�d2e>�ZAGd3d4�d4e>�ZBe=fe?e@eBeAffd5d6�ZCGd7d8�d8e>�ZDGd9d:�d:e>�ZEeCeD�eCeE�Gd;d<�d<�ZFGd=d>�d>e?eFe=�ZGGd?d@�d@eF�ZHeCeHe@eBeAfdA�GdBdC�dC�ZIGdDdE�dEe?eIe=�ZJeCeIe@eBeAfdA�GdFdG�dG�ZKeCeK�GdHdI�dI�ZLGdJdK�dKe?eLe=�ZMGdLdM�dMeL�ZNeCeNe@eBeAfdA�dldNdO�ZOdPdQ�ZPdRdS�ZQdTdU�ZRdVdW�ZSGdXdY�dYe8�ZTGdZd[�d[e8�ZUGd\d]�d]e8�ZVGd^d_�d_e8�ZWGd`da�dae8�ZXGdbdc�dce8�ZYGddde�de�ZZeCeZe@eBeAfdA�Gdfdg�dge=�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)�BrokenProcessPoolT)�addressZmemoryz test too slow on ASAN/MSAN buildcCst�}||_||_||_|S�N)r�_state�
_exception�_result)�state�	exception�result�f�r�8/usr/local/lib/python3.9/test/test_concurrent_futures.py�
create_future)s
r�r�rr�*�rr�
uninitializedcCs||Srr)�x�yrrr�mul;sr%cOs||fSrr)�args�kwargsrrr�capture>sr(cCst�|�td��dS)Nzthis is an exception)�time�sleep�	Exception)�trrr�sleep_and_raiseAs
r-cCs t�|�t|�tj��dSr)r)r*�print�sys�stdout�flush)r,�msgrrr�sleep_and_printEs
r3cCs|adSr��INITIALIZER_STATUS)r#rrr�initJsr6cCstSrr4rrrr�get_init_statusNsr7cCsF|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_failQs


rCc@seZdZdd�ZdS)�MyObjectcCsdSrr��selfrrr�	my_method\szMyObject.my_methodN)�__name__�
__module__�__qualname__rGrrrrrD[srDc@seZdZdd�Zdd�ZdS)�
EventfulGCObjcCs|��|_dSr)�Event�event)rF�mgrrrr�__init__aszEventfulGCObj.__init__cCs|j��dSr)rM�setrErrr�__del__dszEventfulGCObj.__del__N)rHrIrJrOrQrrrrrK`srKcCst�Sr)rD)�_rrr�make_dummy_objecthsrSc@seZdZdd�Zdd�ZdS)�BaseTestCasecCst��|_dSr)r�threading_setup�_thread_keyrErrr�setUpmszBaseTestCase.setUpcCst��tj|j�dSr)r�
reap_children�threading_cleanuprVrErrr�tearDownpszBaseTestCase.tearDownN)rHrIrJrWrZrrrrrTlsrTcs8eZdZdZiZ�fdd�Z�fdd�Zdd�Z�ZS)�
ExecutorMixin�cs^t���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_count�get_context�executor_kwargs�executorrE��	__class__rrrWys


��
��zExecutorMixin.setUpcsT|jjdd�d|_t��|j}tjr8td|dd�|�|dd�t	��
�dS)NT��waitz%.2fs� )�endi,z+synchronization issue: test lasted too long)ri�shutdownr)rbrcr�verboser.Z
assertLessrarZ)rFZdtrjrrrZ�szExecutorMixin.tearDowncCst�|j�Sr)�mprgr]rErrrrg�szExecutorMixin.get_context)	rHrIrJrfrhrWrZrg�
__classcell__rrrjrr[us
r[c@seZdZejZdS)�ThreadPoolMixinN)rHrIrJr	�ThreadPoolExecutorrerrrrrt�srtcs&eZdZejZdZ�fdd�Z�ZS)�ProcessPoolForkMixin�forkcstjdkr|�d�t���S�N�win32zrequire unix system�r/�platformZskipTestrargrErjrrrg�s

z ProcessPoolForkMixin.get_context�	rHrIrJr	�ProcessPoolExecutorrer]rgrsrrrjrrv�srvc@seZdZejZdZdS)�ProcessPoolSpawnMixin�spawnN)rHrIrJr	r}rer]rrrrr~�sr~cs&eZdZejZdZ�fdd�Z�ZS)�ProcessPoolForkserverMixin�
forkservercstjdkr|�d�t���SrxrzrErjrrrg�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�dictr6rhrarWrErjrrrW�s
�zInitializerMixin.setUpcs6�fdd�t�j�D�}|D]}��|��d�qdS)Ncsg|]}�j�t��qSr)ri�submitr7��.0rRrErr�
<listcomp>�s�z5InitializerMixin.test_initializer.<locals>.<listcomp>r�)�rangerf�assertEqualr)rFr	rrrEr�test_initializer�s

�z!InitializerMixin.test_initializer)rHrIrJrfrWr�rsrrrjrr��sr�cs6eZdZdZ�fdd�Zdd�Zejdd��Z�Z	S)�FailingInitializerMixinr�csZt|d�r4|��|_|j��|_tt|jfd�|_nd|_d|_ttd�|_t��	�dS)Nr]r�)r�)
rdrgr`�QueuerAr�rCrhrarWrErjrrrW�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_loggedrir�r7r�assertRaisesrr)rb�_broken�failr*)rF�futurercrrrr��s&
z(FailingInitializerMixin.test_initializerc#s�|jdurFdVg}z|�|j�����qWq~tjyBYq~0n8|�dd��}dVWd�n1sn0Y|j}|�t	�fdd�|D��|�dS)Nr8r9c3s|]}�|vVqdSrr)r��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��
contextlib�contextmanagerr�rsrrrjrr��s
r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ExecutorShutdownTestcCs$|j��|�t|jjtdd�dS)Nr�r\)rirpr��RuntimeErrorr��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_shutdowns

�
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_shutdown2s
�z;ExecutorShutdownTest.test_submit_after_interpreter_shutdowncs6�fdd�td�D�}�j��|D]}|��q$dS)Ncsg|]}�j�tjd��qS�r:�rir�r)r*r�rErrr�Or�z=ExecutorShutdownTest.test_hang_issue12364.<locals>.<listcomp>�2)r�rirpr)rF�fsrrrEr�test_hang_issue12364Ns
z)ExecutorShutdownTest.test_hang_issue12364cs��jdksJd���fdd�td�D�}�jjdd�dd�|D�}��t|�d	�d
d�|D�}|D],}�j|��d|j��d���	|�
��qf��t|�d
�dS)Nr\ztest needs few workerscsg|]}�j�tjd��qSr�r�r�rErrr�Vr�z<ExecutorShutdownTest.test_cancel_futures.<locals>.<listcomp>r�T)�cancel_futurescSsg|]}|��r|�qSr��	cancelled�r��futrrrr�[r��cSsg|]}|��s|�qSrr�r�rrrr�ar�zfut._state=r�r)rfr�rirpZ
assertGreater�lenr��doner�assertIsNoner)rFr�r�Zothersr�rrEr�test_cancel_futuresTsz(ExecutorShutdownTest.test_cancel_futurescCsZ|jtjkrt�d��tddj|jjt|dd�d��\}}}|�	|�|�
|��d�dS)z�shutdown(wait=False) doesn't hang at exit with running futures.

        See https://github.com/python/cpython/issues/83386.
        z9Hangs, see https://github.com/python/cpython/issues/83386r�a�if True:
            from concurrent.futures import {executor_type}
            from test.test_concurrent_futures import sleep_and_print
            if __name__ == "__main__":
                if {context!r}: multiprocessing.set_start_method({context!r})
                t = {executor_type}(max_workers=3)
                t.submit(sleep_and_print, 1.0, "apple")
                t.shutdown(wait=False)
            r]Nr�r�)rer	r}�unittest�SkipTestrr�rHr�r�r�r�r�rrr�test_hang_gh83386ks�
�

z&ExecutorShutdownTest.test_hang_gh83386N)	rHrIrJr�r�r�r�r�r�rrrrr�sr�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ThreadPoolShutdownTestcCs|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_lockr�)�	threading�	Semaphorer�rir�r�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	rur��list�map�absr�r�r�)rF�erir,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��r��r�vrrrr��r�z<ThreadPoolShutdownTest.test_del_shutdown.<locals>.<listcomp>)	r	rur�r�r�r�r��all�zip�rFri�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�rrrr��r�z@ThreadPoolShutdownTest.test_shutdown_no_wait.<locals>.<listcomp>)
r	rur�r�r�r�rpr�r�r�r�rrr�test_shutdown_no_wait�s
z,ThreadPoolShutdownTest.test_shutdown_no_waitcCsTtjddd�}|�ttdd��|j}~t��|D]}|�|j	d�|�
�q4dS)Nr\ZSpecialPool)r_Zthread_name_prefixr�z^SpecialPool_[0-4]$�r	rur�r�r�r�r�
gc_collect�assertRegexr�r��rFrir�r,rrr�test_thread_names_assigned�s�z1ThreadPoolShutdownTest.test_thread_names_assignedcCsRtjdd�}|�ttdd��|j}~t��|D]}|�|j	d�|�
�q2dS)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)
            )rer�)rr�rerHr�r�r�r�rrr�test_cancel_futures_wait_false�s
�

z5ThreadPoolShutdownTest.test_cancel_futures_wait_falseN)
rHrIrJr�r�r�r�r�rrrrrrr��s	

r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ProcessPoolShutdownTestcCs�dd�}|��}|jdd�dkr(|j}nd}|�d�}td�D]}|j�||�q>|�t|jj	�|�td�D]}|�
�qn|jj	}|j��|��D]}|�
�q�dS)NcSs|��dSrr�r�rrrr��szFProcessPoolShutdownTest.test_processes_terminate.<locals>.acquire_lockF��
allow_nonerwr�r)rg�get_start_methodrfr�r�rir�r�r��
_processesr�rp�valuesr�)rFr�r`Zexpected_num_processesr�rR�	processes�prrr�test_processes_terminate�s


z0ProcessPoolShutdownTest.test_processes_terminatec
Csttjd|��d��8}|j}|�t|�ttdd���gd��Wd�n1sP0Y|�	�D]}|�
�qbdS)Nr\r^r�r�)r	r}rgrr�r�r�r�r�rr�)rFr�rr	rrrr��s��"z5ProcessPoolShutdownTest.test_context_manager_shutdowncCs�tjd|��d�}|�ttdd��}|j}|j}|j}|j}~t	�
�|��|��D]}|��qV|�
�tdd�t|tdd��D��s�J�dS)Nr\r^r�cSsg|]\}}|t|�k�qSrr�r�rrrr�r�z=ProcessPoolShutdownTest.test_del_shutdown.<locals>.<listcomp>)r	r}rgr�r�r��_executor_manager_threadr�_call_queuerr�r�r�join_threadr�r�)rFrir��executor_manager_threadr�
call_queuer	rrrr�s�
z)ProcessPoolShutdownTest.test_del_shutdowncCs�tjd|��d�}|�ttdd��}|j}|j}|j}|j	dd�|�
�|��D]}|�
�qR|��t
dd�t|tdd��D��s�J�dS)Nr\r^r�FrlcSsg|]\}}|t|�k�qSrr�r�rrrr�,r�zAProcessPoolShutdownTest.test_shutdown_no_wait.<locals>.<listcomp>)r	r}rgr�r�r�rrrrpr�rr
r�r�)rFrir�rrrr	rrrr�s�
z-ProcessPoolShutdownTest.test_shutdown_no_waitN)rHrIrJr
r�r�r�rrrrr�s
r)r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�	WaitTestscCsH|j�tjd�}tj||gtjd�\}}|�|h|�|�t�|�dS�N��?��return_when)	rir�r)r*r	rm�
ALL_COMPLETEDr�rP)rFr�r��not_donerrr�
test_203696s
�
zWaitTests.test_20369cCsd|j�tdd�}|j�tjd�}tjt||gtjd�\}}|�	t
|g�|�|�	t
t|g�|�dS)N�r�rr)rir�r%r)r*r	rm�CANCELLED_FUTURE�FIRST_COMPLETEDr�rP)rF�future1�future2r�rrrr�test_first_completed?s�
zWaitTests.test_first_completedcCsT|j�tjd�}tjtt|gtjd�\}}|�	t
ttg�|�|�	t
|g�|�dSr)rir�r)r*r	rm�CANCELLED_AND_NOTIFIED_FUTURE�SUCCESSFUL_FUTURErr�rP�rFr�finished�pendingrrr�+test_first_completed_some_already_completedJs�

�z5WaitTests.test_first_completed_some_already_completedcCsr|j�tdd�}|j�td�}|j�tjd�}tj|||gtjd�\}}|�	t
||g�|�|�	t
|g�|�dS)Nr�rrr�r)rir�r%r-r)r*r	rm�FIRST_EXCEPTIONr�rP)rFrrZfuture3r!r"rrr�test_first_exceptionVs�
zWaitTests.test_first_exceptioncCsl|j�tdd�}|j�tjd�}tjttt	||gtj
d�\}}|�ttt	|g�|�|�tt|g�|�dS)Nrrrr)
rir��divmodr)r*r	rmrrrr$r�rP�rFrrr!r"rrr�*test_first_exception_some_already_completebs"��
��z4WaitTests.test_first_exception_some_already_completecCsP|j�tjd�}tjt|gtjd�\}}|�t	tg�|�|�t	|g�|�dS)Nr�r)
rir�r)r*r	rm�EXCEPTION_FUTUREr$r�rPr rrr�'test_first_exception_one_already_failedrs�
z1WaitTests.test_first_exception_one_already_failedcCsj|j�tdd�}|j�tdd�}tjttt||gtj	d�\}}|�
tttt||g�|�|�
t�|�dS)Nr�rrr)rir�r&r%r	rmrrr)rr�rPr'rrr�test_all_completed|s(��
��zWaitTests.test_all_completedcCsn|j�tdd�}|j�tjd�}tjttt	||gdtj
d�\}}|�tttt	|g�|�|�t|g�|�dS)N��r\)�timeoutr)
rir�r%r)r*r	rmrr)rrr�rPr'rrr�test_timeout�s&��
��zWaitTests.test_timeoutN)rHrIrJrrr#r%r(r*r+r/rrrrr5s	
rc@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)rir�)r�r�)r1rFrr�	<setcomp>�r�z>ThreadPoolWaitTests.test_pending_calls_race.<locals>.<setcomp>�dr)
r�rLr/�getswitchinterval�setswitchintervalr�rPr	rmr)rFZoldswitchintervalr�r)rMr1rFr�test_pending_calls_race�s
z+ThreadPoolWaitTests.test_pending_calls_raceN)rHrIrJr6rrrrr0�sr0c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AsCompletedTestscCsV|j�tdd�}|j�tdd�}tt�ttt||g��}|�	tttt||g�|�dS)Nr�rr-r,)
rir�r%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.)
rir�r)r*rPr	r8rr)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)r�rrrrr��sz;AsCompletedTests.test_duplicate_futures.<locals>.<listcomp>r�r�)
rir�r)r*r	r8�	itertools�repeatr�r�)rFrr9rrr�test_duplicate_futures�s
�z'AsCompletedTests.test_duplicate_futurescCs�dd�td�D�}|�ttd��|�ttdd��|�tj��Ntj|dd�D].}|�	|�t
�|�}~t�
�|�|��qPWd�n1s�0Y|d�d	�t�|�D]@}|�	|�t
�|�}~t�
�|�|��|r�|d�d	�q�dS)
NcSsg|]
}t��qSr)rr�rrrr��r�zGAsCompletedTests.test_free_reference_yielded_future.<locals>.<listcomp>�rr r!rr;�test)r�r�rr
rr�r	r=r8�remove�weakref�refrr�r��
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)Nrr;z2 (of 4) futures unfinished)r�PENDING_FUTURE�RUNNING_FUTURErr�r	r=r�r8r��strr)rFrHr�rrr�"test_correct_timeout_exception_msgs�0z3AsCompletedTests.test_correct_timeout_exception_msgN)rHrIrJr:r>rArJrNrrrrr7�s

r7c@sZeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
d
d��Zdd�Zdd�Z
dS)�ExecutorTestcCs$|j�tdd�}|�d|���dS)Nr�rB�)rir�r�r�r�rFr�rrr�test_submitszExecutorTest.test_submitcCs�|jjtddd�}|�d|���|jjtdddd�}|�|��dddd�f�|�t�� |jjtdd	�Wd�n1s�0Y|�t��|jjdd
�Wd�n1s�0YdS)Nr�rB)r$�r�r�)rF�fn)r�)rT�arg)rU)rir�r%r�rr(r��	TypeErrorrQrrr�test_submit_keywords.z ExecutorTest.test_submit_keywordc	Csx|�t|j�ttd�td���ttttd�td����|�t|jjttd�td�dd��ttttd�td����dS)N�
r���	chunksize)r�r�rir�r�r�rErrr�test_map s��zExecutorTest.test_mapcCsJ|j�tgd�gd��}|�|��d�|�|��d�|�t|j�dS)N)r�r�r�r�)r�r�rr\)rr�)rir�r&r��__next__r��ZeroDivisionError)rFr�rrr�test_map_exception)szExecutorTest.test_map_exceptioncCsdg}z,|jjtjgd�dd�D]}|�|�qWntjyDYn0|�d�|�ddg|�dS)N)rrr,r\r;zexpected TimeoutError)	rir�r)r*r�r	r=r�r�)rF�resultsr�rrr�test_map_timeout/s
�

zExecutorTest.test_map_timeoutcCs(|j�tdg|jd�|j��dS)Nr�r�)rir�rMrfrprErrr�test_shutdown_race_issue12456=sz*ExecutorTest.test_shutdown_race_issue12456csPt�}t���t�|�fdd��}|j�|j�~�jt	j
d�}|�|d�dS)Ncs���Sr)rP)�obj�Zmy_object_collectedrr�<lambda>Kr�z7ExecutorTest.test_no_stale_references.<locals>.<lambda>r;z-Stale reference not collected within timeout.)rDr�rLrErFrir�rGrmr�
SHORT_TIMEOUTr�)rFZ	my_objectZmy_object_callbackZ	collectedrrcr�test_no_stale_referencesDs��z%ExecutorTest.test_no_stale_referencesc	CsFdD]<}|�td��|j|d�Wd�q1s60YqdS)N)r���z"max_workers must be greater than 0r�)�assertRaisesRegexr@re)rF�numberrrr�test_max_workers_negativeTs
�z&ExecutorTest.test_max_workers_negativecCs<|j�ttd��D]$}t�|�}~t��|�|��qdS)NrX)	rir�rSr�rErFrr�r�)rFrbrIrrr�test_free_reference[s

z ExecutorTest.test_free_referenceN)rHrIrJrRrWr[r^r`rarZcpython_onlyrfrjrkrrrrrOs
	
rOc@sFeZdZdd�Zdd�Zdd�Zdd�Ze�e	e
d	�d
�dd��Zd
S)�ThreadPoolExecutorTestcsDg��fdd�}|j�|td��|jjdd�|��td��dS)zTests verifying issue 11777.cs��|�dSr)r�)�n�r!rr�record_finishediszRThreadPoolExecutorTest.test_map_submits_without_iteration.<locals>.record_finishedrXTrlN)rir�r�rpZassertCountEqual)rFrorrnr�"test_map_submits_without_iterationfs
z9ThreadPoolExecutorTest.test_map_submits_without_iterationcCs0|��}tdt��pdd�}|�|j|�dS)N� r�r�)re�min�os�	cpu_countr��_max_workers)rFriZexpectedrrr�test_default_workerspsz+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�wsz<ThreadPoolExecutorTest.test_saturation.<locals>.acquire_lockr�Trl)rer�r�r�rur�r�r�r�r�rp)rFrir�r�r�rrr�test_saturationus


z&ThreadPoolExecutorTest.test_saturationcCs`|��}|�tdd���|�tdd���|�tdd���|�t|j�d�|jdd	�dS)
Nrr�r,r-r��r�Trl)rer�r%rr�r�r�rp�rFrirrr�test_idle_thread_reuse�sz-ThreadPoolExecutorTest.test_idle_thread_reuse�register_at_forkzneed os.register_at_forkc
s��fdd��t�d��h}|��|�td�D]B}tjdt�d�d��}|�t�Wd�q,1sd0Yq,Wd�n1s�0YdS)Ncs|��|�dSr�r�)�poolr}rrr��szEThreadPoolExecutorTest.test_hang_global_shutdown_lock.<locals>.submitr�r�rw)r`)r	rur�r�r}rrrg�tuple)rFr~rR�workersrr}r�test_hang_global_shutdown_lock�sz5ThreadPoolExecutorTest.test_hang_global_shutdown_lockN)rHrIrJrprvrxr{r��
skipUnlessrdrsr�rrrrrles

rlc@steZdZe�ejdkd�dd��Zdd�Zdd�Z	e
d	d
��Zdd�Ze
�d
�dd��Zdd�Zdd�Zdd�ZdS)�ProcessPoolExecutorTestryzWindows-only process limitcCs<|�td��tjdd�Wd�n1s.0YdS)Nzmax_workers must be <= 61�>r�)rhr@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�rB)
rir�r)r*�next�iterrr�	terminater�rrr�)rFr	r	r�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�(rgrY)r�rir�r�r�rrErr�bad_map�sz;ProcessPoolExecutorTest.test_map_chunksize.<locals>.bad_mapr�r,rYr�)r�r�r�r�r�rir�r@)rFr�rFrrEr�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)rir�r�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|�}|��|�|jj	dd��d}t
��|��|�
�dS)Nr�r;)rg�ManagerrKrir��idrr�rMrmrr�rpr�)rFrNrbr�rrr�test_ressources_gced_in_workers�sz7ProcessPoolExecutorTest.test_ressources_gced_in_workerscCsj|j}|��}|�d�}d|j}t|�D]}|�|j�q*|�t|j	�|j�t|�D]}|�
�qXdS)Nrrw)rirgr�rur�r�r�r�r�rr�)rFrir`r�Z	job_countrRrrrrx�s

z'ProcessPoolExecutorTest.test_saturationcCs~|j}|jdksJ�|��jdd�dkr2t�d��|�tdd���|�tdd	���|�td
d���|�	t
|j�d�dS)
Nr�Frrw�(Incompatible with the fork start method.rr�r,r-r�ryr�)rirurgrr�r�r�r%rr�r�rrzrrr�test_idle_process_reuse_one�s
z3ProcessPoolExecutorTest.test_idle_process_reuse_onecCs�|j}|jdksJ�|��jdd�dkr2t�d��|�tdd���|�tdd	�|�td	d
���|�tdd�|�td
d���|�tdd�|�	t
|j�d�|��dS)Nr\Frrwr��r-�!����r�r�r�	r�)
rirurgrr�r�r�r%rZassertLessEqualr�rrprzrrr� test_idle_process_reuse_multiple�s
z8ProcessPoolExecutorTest.test_idle_process_reuse_multipleN)rHrIrJr�r�r/r{r�r�r��classmethodr�r�rZrequires_hashdigestr�rxr�r�rrrrr��s



r�cCs*|rt�|�ddl}|��|��dS)zInduces a segfault.rN)r)r*�faulthandler�disableZ_sigsegv)�delayr�rrr�_crashs

r�cCst�d�dS)z#Induces a sys exit with exitcode 1.r�N)r/�exitrrrr�_exitsr�cCs
|��dS)z-Function that raises an Exception in process.Nr)�Errrrr�_raise_error!sr�cCsddl}|��t_|��dS)z@Function that raises an Exception in process and ignores stderr.rN)�io�StringIOr/�stderr)r�r�rrr�_raise_error_ignore_stderr&s
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__4szCrashAtPickle.__reduce__N�rHrIrJ�__doc__r�rrrrr�2sr�c@seZdZdZdd�ZdS)�CrashAtUnpicklez7Bad object that triggers a segfault at unpickling time.cCstdfS�Nrr�rErrrr�:szCrashAtUnpickle.__reduce__Nr�rrrrr�8sr�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�FszExitAtUnpickle.__reduce__Nr�rrrrr�Dsr�c@seZdZdZdd�ZdS)�
ErrorAtPicklez3Bad object that triggers an error at pickling time.cCsddlm}|d��dS)NrrzError in pickle)�pickler)rFrrrrr�LszErrorAtPickle.__reduce__Nr�rrrrr�Jsr�c@seZdZdZdd�ZdS)�ErrorAtUnpicklez5Bad object that triggers an error at unpickling time.cCsddlm}t|ffS)Nr)�UnpicklingError)r�r�r�)rFr�rrrr�SszErrorAtUnpickle.__reduce__Nr�rrrrr�Qsr�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�)rFrir�r�rr�r	rrr�_fail_on_deadlock[s
&
z&ExecutorDeadlockTest._fail_on_deadlockF��
ignore_stderrc	Gs�|jjdd�|jd|��d�}|j|g|�R�}|r@t��}nt��}z`|�	|��B|�|j
|jd�Wd�n1s~0YWd�n1s�0YWntj
y�|�|�Yn0|jdd�dS)NTrlr�r^r;)rirprergr�rr�r��nullcontextr�r�TIMEOUTr	r=r�)rF�error�funcr�r&rir�r�rrr�_check_crashns�
Nz!ExecutorDeadlockTest._check_crashcCs|�ttt��dSr)r�rr�r�rErrr�test_error_at_task_pickle�sz.ExecutorDeadlockTest.test_error_at_task_picklecCs|�ttt��dSr)r�rr�r�rErrr�test_exit_at_task_unpickle�sz/ExecutorDeadlockTest.test_exit_at_task_unpicklecCs|�ttt��dSr)r�rr�r�rErrr�test_error_at_task_unpickle�sz0ExecutorDeadlockTest.test_error_at_task_unpicklecCs|�ttt��dSr)r�rr�r�rErrr�test_crash_at_task_unpickle�sz0ExecutorDeadlockTest.test_crash_at_task_unpicklecCs|�tt�dSr)r�rr�rErrr�%test_crash_during_func_exec_on_worker�sz:ExecutorDeadlockTest.test_crash_during_func_exec_on_workercCs|�tt�dSr)r��
SystemExitr�rErrr�$test_exit_during_func_exec_on_worker�sz9ExecutorDeadlockTest.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�|jd|��d��b}||_|jtdd�}|jdd�|�t��|��Wd�n1sj0YWd�n1s�0YdS)NTrlr�r^r:)r�)	rirprergr�r�r�rr)rFrirrrr�test_shutdown_deadlock�s�z+ExecutorDeadlockTest.test_shutdown_deadlockc	Cs�|jjdd�|jd|��d��x}||_|�td���|j}|�tt��}|jdd�|�	t
��|��Wd�n1s�0YWd�n1s�0Y|��dS)NTrlr�r^r F)rirprergr�r�rrr�r�rr�)rFriZexecutor_managerrrrr�test_shutdown_deadlock_pickle�s�Dz2ExecutorDeadlockTest.test_shutdown_deadlock_pickleN)rHrIrJrrer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�Xs"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_resultrrrT�sz6FutureTests.test_done_callback_with_result.<locals>.fnr\)r�add_done_callbackrGr��rFrTrrr�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_exceptionrrrT�sz9FutureTests.test_done_callback_with_exception.<locals>.fnrC�rC)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_cancelledrrrTsz6FutureTests.test_done_callback_with_cancel.<locals>.fn)rr�r��cancelr�rr�r�test_done_callback_with_cancels
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_fnsz9FutureTests.test_done_callback_raises.<locals>.raising_fncsd�dS)NTrr�)�
fn_was_calledrrrTsz1FutureTests.test_done_callback_raises.<locals>.fnr\zException: doh!)rr�rr�rGr�r�r�)rFr�r�rTrr)r�r�r�test_done_callback_raisess





z%FutureTests.test_done_callback_raisescs:d��fdd�}t�}|�d�|�|�|�d��dS)Ncs|���dSrr�r�r�rrrT$sz=FutureTests.test_done_callback_already_successful.<locals>.fnr\)rrGr�r�r�rr�r�%test_done_callback_already_successful"s

z1FutureTests.test_done_callback_already_successfulcs@d��fdd�}t�}|�td��|�|�|�d�j�dS)Ncs|���dSrr�r�r�rrrT/sz9FutureTests.test_done_callback_already_failed.<locals>.fnrCr�)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�rrrT:sz<FutureTests.test_done_callback_already_cancelled.<locals>.fn)rr�r�r�r�rr�r�$test_done_callback_already_cancelled8s
z0FutureTests.test_done_callback_already_cancelledcCsnt���R}dd�}t�}|�d�|�|�|�d|���|�d|���Wd�n1s`0YdS)NcSstd��dS)Nr�r�r�rrrr�EszKFutureTests.test_done_callback_raises_already_succeeded.<locals>.raising_fnr\zexception calling callback forr�)rr�rrGr�r�r�)rFr�r�rrrr�+test_done_callback_raises_already_succeededCs


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��reprrKrLrrr)rrErrr�	test_reprSs(
�
�
�
���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�rKr�rLr�rrr)rrErrr�test_cancelled~szFutureTests.test_cancelledcCsX|�t���|�t���|�t���|�t���|�t���|�t���dSr)	r�rKr�rLr�rrr)rrErrr�	test_done�szFutureTests.test_donecCsX|�t���|�t���|�t���|�t���|�t���|�t���dSr)	r�rK�runningr�rLrrr)rrErrr�test_running�szFutureTests.test_runningcCsz|jtjtjdd�|jtjtjdd�|jtjtjdd�|jtjtjdd�|jt	t
jdd�|�tjdd�d�dS)Nrr;r )
r�r	r=rKrrL�CancelledErrorrrrr)r�rrErrr�test_result_with_timeout�s����z$FutureTests.test_result_with_timeoutcsJ�fdd�}ttd��tj|d�}|��|��jdd�d�|��dS)Ncst�d���d�dS)Nr�r )r)r*rGr�r�rr�notification�s
z:FutureTests.test_result_with_success.<locals>.notificationr��targetr\r;r )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>.notificationrrr;)rr
r�r
rr�r	rrrrer�rrr	r�test_result_with_cancel�s
�z#FutureTests.test_result_with_cancelcCs�|jtjtjdd�|jtjtjdd�|jtjtjdd�|jtjtjdd�|�	t
tjdd�t��|�
tjdd�d�dS)Nrr;)r�r	r=rKrrLrrrr��
isinstancer)rr�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*�
_conditionrrrr�
notify_allrr	rrr
�s

z=FutureTests.test_exception_with_success.<locals>.notificationrrr;)rr
r�r
rr�rrrrerr�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
rGrhr	�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�rhr	rr+r�r)rFrr�rrr�test_multiple_set_exception�s

�*z'FutureTests.test_multiple_set_exceptionN)rHrIrJr�r�r�r�r�r�r�r�r�rrrrrrrrrrrrrrrr��s(
r�cCs.t�tjj�t��}tjtjg|�R�dSr)r�ZaddModuleCleanup�multiprocessing�util�_cleanup_testsrrUrY)�thread_inforrr�setUpModule�sr�__main__)N)N)_rCr�
import_moduleZ*skip_if_broken_multiprocessing_synchronizeZtest.supportrZtest.support.script_helperrr�r?r;Zlogging.handlersrrsr�r/r�r)r�rEr�r�
concurrentr	�concurrent.futures._baser
rrr
rrrZconcurrent.futures.processrZmultiprocessing.processrZmultiprocessing.utilrrZcheck_sanitizerr�rrKrLrrrr)rr5r%r(r-r3r6r7rC�objectrDrKrSZTestCaserTr[rtrvr~r�r�r�r�r�r�rrr0r7rOrlr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrH�mainrrrr�<module>s�
$






	!

��
8m^O��m��RV4u��
	
��


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists