
    ;eW                        d dl mZ d dlmZ d dlmZ  ej        d           d dlmZ d dlmZ d dl	Z	d dl
Z
d dlZd dlmZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd d	lmZ d d
lmZ d dlmZmZmZmZmZm Z m!Z! d dl"m#Z#m$Z$ d dl%Z&d dl'Z&d dl&Z( ej)        dd          r ej*        d          eddfdZ+ e+e          Z, e+e          Z- e+e          Z. e+e          Z/ e+e e0                      Z1 e+ed          Z2da3d Z4d Z5d Z6d Z7d Z8d Z9d^dZ: G d de;          Z< G d d           Z=d! Z> G d" d#ej?                  Z@ G d$ d%          ZA G d& d'eA          ZB G d( d)eA          ZC G d* d+eA          ZD G d, d-eA          ZEe@feBeCeEeDffd.ZF G d/ d0eA          ZG G d1 d2eA          ZH eFeG            eFeH            G d3 d4          ZI G d5 d6eBeIe@          ZJ G d7 d8eI          ZK eFeKeCeEeDf9            G d: d;          ZL G d< d=eBeLe@          ZM eFeLeCeEeDf9            G d> d?          ZN eFeN            G d@ dA          ZO G dB dCeBeOe@          ZP G dD dEeO          ZQ eFeQeCeEeDf9           d^dFZRdG ZSdH ZTdI ZUdJ ZVdK ZW G dL dMe;          ZX G dN dOe;          ZY G dP dQe;          ZZ G dR dSe;          Z[ G dT dUe;          Z\ G dV dWe;          Z] G dX dY          Z^ eFe^eCeEeDf9            G dZ d[e@          Z_d\ Z`ead]k    r ejb                     dS dS )_    )support)import_helper)threading_helper_multiprocessing)hashlib_helper)assert_python_okN)QueueHandlerPicklingError)futures)PENDINGRUNNING	CANCELLEDCANCELLED_AND_NOTIFIEDFINISHEDFutureBrokenExecutor)BrokenProcessPool_check_system_limitsT)addressmemoryz test too slow on ASAN/MSAN buildc                 L    t                      }| |_        ||_        ||_        |S N)r   _state
_exception_result)state	exceptionresultfs       3/usr/lib/python3.11/test/test_concurrent_futures.pycreate_futurer"   *   s%    AAHALAIH    r   r   r   *   r   r   uninitializedc                     | |z  S r    )xys     r!   mulr-   ;   s    q5Lr#   c                  
    | |fS r   r*   )argskwargss     r!   capturer1   >   s    <r#   c                 H    t          j        |            t          d          )Nzthis is an exception)timesleep	Exception)ts    r!   sleep_and_raiser7   A   s    JqMMM
*
+
++r#   c                     t          j        |            t          |           t          j                                         d S r   )r3   r4   printsysstdoutflush)r6   msgs     r!   sleep_and_printr>   E   s4    JqMMM	#JJJJr#   c                 
    | a d S r   INITIALIZER_STATUS)r+   s    r!   initrB   J   s    r#   c                      t           S r   r@   r*   r#   r!   get_init_statusrD   N   s    r#   c                     | Rt          j        d          }|                    t          |                      |                    d           d|_        t          j        d           t          d          )Nconcurrent.futuresCRITICALF皙?zerror in initializer)	logging	getLogger
addHandlerr	   setLevel	propagater3   r4   
ValueError)	log_queueloggers     r!   	init_failrQ   Q   sk    "#788,y11222
### JsOOO
+
,
,,r#   c                       e Zd Zd ZdS )MyObjectc                     d S r   r*   selfs    r!   	my_methodzMyObject.my_method\   s    r#   N)__name__
__module____qualname__rW   r*   r#   r!   rS   rS   [   s#            r#   rS   c                       e Zd Zd Zd ZdS )EventfulGCObjc                 8    |                                 | _        d S r   )Eventevent)rV   mgrs     r!   __init__zEventfulGCObj.__init__a   s    YY[[


r#   c                 8    | j                                          d S r   )r_   setrU   s    r!   __del__zEventfulGCObj.__del__d   s    
r#   N)rX   rY   rZ   ra   rd   r*   r#   r!   r\   r\   `   s2        ! ! !    r#   r\   c                     t                      S r   )rS   )_s    r!   make_dummy_objectrg   h   s    ::r#   c                       e Zd Zd Zd ZdS )BaseTestCasec                 6    t          j                    | _        d S r   )r   threading_setup_thread_keyrU   s    r!   setUpzBaseTestCase.setUpm   s    +;==r#   c                 R    t          j                     t          j        | j          d S r   )r   reap_childrenr   threading_cleanuprl   rU   s    r!   tearDownzBaseTestCase.tearDownp   s(    *D,<====r#   N)rX   rY   rZ   rm   rq   r*   r#   r!   ri   ri   l   s2        > > >> > > > >r#   ri   c                   6     e Zd ZdZi Z fdZ fdZd Z xZS )ExecutorMixin   c                 :   t                                                       t          j                    | _        t          | d          r3 | j        d| j        |                                 d| j	        | _
        d S  | j        dd| j        i| j	        | _
        d S )Nctxmax_workers
mp_contextrx   r*   )superrm   r3   	monotonict1hasattrexecutor_typeworker_countget_contextexecutor_kwargsexecutorrV   	__class__s    r!   rm   zExecutorMixin.setUpy   s    .""4 	(.D. ( -++--( ( &( (DMMM
 /D. ( ( -(&( (DMMMr#   c                 0   | j                             d           d | _         t          j                    | j        z
  }t
          j        rt          d|z  d           |                     |dd           t                      
                                 d S )NTwaitz%.2fs )endi,  z+synchronization issue: test lasted too long)r   shutdownr3   r{   r|   r   verboser9   
assertLessrz   rq   )rV   dtr   s     r!   rq   zExecutorMixin.tearDown   s    D)))^'? 	)'B,C((((C!NOOOr#   c                 4    t          j        | j                  S r   )mpr   rv   rU   s    r!   r   zExecutorMixin.get_context   s    ~dh'''r#   )	rX   rY   rZ   r   r   rm   rq   r   __classcell__r   s   @r!   rs   rs   u   sj        LO( ( ( ( (	 	 	 	 	( ( ( ( ( ( (r#   rs   c                       e Zd Zej        ZdS )ThreadPoolMixinN)rX   rY   rZ   r   ThreadPoolExecutorr~   r*   r#   r!   r   r      s        .MMMr#   r   c                   0     e Zd Zej        ZdZ fdZ xZS )ProcessPoolForkMixinforkc                     	 t                       n%# t          $ r |                     d           Y nw xY wt          j        dk    r|                     d           t                                                      S N.ProcessPoolExecutor unavailable on this systemwin32zrequire unix systemr   NotImplementedErrorskipTestr:   platformrz   r   r   s    r!   r   z ProcessPoolForkMixin.get_context       	L """"" 	L 	L 	LMMJKKKKK	L<7""MM/000ww""$$$    44	rX   rY   rZ   r   ProcessPoolExecutorr~   rv   r   r   r   s   @r!   r   r      sE        /M
C% % % % % % % % %r#   r   c                   0     e Zd Zej        ZdZ fdZ xZS )ProcessPoolSpawnMixinspawnc                     	 t                       n%# t          $ r |                     d           Y nw xY wt                                                      S )Nr   )r   r   r   rz   r   r   s    r!   r   z!ProcessPoolSpawnMixin.get_context   sf    	L """"" 	L 	L 	LMMJKKKKK	Lww""$$$r   r   r   s   @r!   r   r      sE        /M
C% % % % % % % % %r#   r   c                   0     e Zd Zej        ZdZ fdZ xZS )ProcessPoolForkserverMixin
forkserverc                     	 t                       n%# t          $ r |                     d           Y nw xY wt          j        dk    r|                     d           t                                                      S r   r   r   s    r!   r   z&ProcessPoolForkserverMixin.get_context   r   r   r   r   s   @r!   r   r      sE        /M
C% % % % % % % % %r#   r   c                     d }|D ]O} ||j                    || j                   d}t          || f|fz   |z   i           }|t                      |<   Pd S )Nc                     |                      d          r
| d d         S |                      d          r
| d d         S | S )N)MixinTestsTest)endswith)names    r!   strip_mixinz*create_executor_tests.<locals>.strip_mixin   sL    ==+,, 	9]]6"" 	9Kr#   r   )rX   typeglobals)mixinbasesexecutor_mixinsr   exer   clss          r!   create_executor_testsr      s    
     ;s|,,,kk%..I.I.I.IK4%SF*U2B77		$	 r#   c                   (     e Zd ZdZ fdZd Z xZS )InitializerMixin   c                     da t          t          d          | _        t	                                                       d S )Nr(   )initializedinitializerinitargs)rA   dictrB   r   rz   rm   r   s    r!   rm   zInitializerMixin.setUp   s:    ,#-= ?  ?  ?r#   c                       fdt           j                  D             }|D ]*}                     |                                d           +d S )Nc                 N    g | ]!}j                             t                    "S r*   )r   submitrD   .0rf   rV   s     r!   
<listcomp>z5InitializerMixin.test_initializer.<locals>.<listcomp>   s9     6 6 6 =''88 6 6 6r#   r   )ranger   assertEqualr   )rV   r   r    s   `  r!   test_initializerz!InitializerMixin.test_initializer   sr    6 6 6 6!$"3446 6 6  	8 	8AQXXZZ7777	8 	8r#   )rX   rY   rZ   r   rm   r   r   r   s   @r!   r   r      sL        L    8 8 8 8 8 8 8r#   r   c                   H     e Zd ZdZ fdZd Zej        d             Z xZ	S )FailingInitializerMixinr   c                 j   t          | d          rY|                                 | _        | j                                        | _        t          t          | j        f          | _        n(d | _        d | _        t          t                    | _        t                      	                                 d S )Nrv   r   )r   )
r}   r   ry   QueuerO   r   rQ   r   rz   rm   r   s    r!   rm   zFailingInitializerMixin.setUp   s    4 	?"..00DO!_2244DN#'I26.1B$D $D $DD  
 #DO!DN#'I#>#>#>D r#   c                    |                      d          5  	 | j                            t                    }|                     t
                    5  |                                 d d d            n# 1 swxY w Y   n# t
          $ r Y nw xY wt          j                    }| j        j	        sOt          j                    |z
  dk    r| 
                    d           t          j        d           | j        j	        O|                     t
                    5  | j                            t                     d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nz ValueError: error in initializerrt   zexecutor not broken after 5 s.g{Gz?)_assert_loggedr   r   rD   assertRaisesr   r   r3   r{   _brokenfailr4   )rV   futurer|   s      r!   r   z(FailingInitializerMixin.test_initializer   s     !CDD 	6 	6$--o>>
 &&~66 $ $MMOOO$ $ $ $ $ $ $ $ $ $ $ $ $ $ $	 "    !!Bm+ !>##b(1,,II>???
4    m+ !
 "">22 6 6$$_5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6!	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s|   EA>EA2&E2A6	6E9A6	:E>
BE
BBE E6EE	E	E	
EE!Ec              #     K   | j         \d V  g }	 	 |                    | j                                                                                    ?# t          j        $ r Y n=w xY w|                     dd          5 }d V  d d d            n# 1 swxY w Y   |j        }|                     t          fd|D                       |           d S )NTrF   rG   c              3       K   | ]}|v V  	d S r   r*   )r   liner=   s     r!   	<genexpr>z9FailingInitializerMixin._assert_logged.<locals>.<genexpr>  s'      ;;DC4K;;;;;;r#   )
rO   append
get_nowait
getMessagequeueEmpty
assertLogsoutput
assertTrueany)rV   r=   r   cms    `  r!   r   z&FailingInitializerMixin._assert_logged  s7     >%EEEFLMM$.";";"="="H"H"J"JKKKL;    !5zBB b              YF;;;;F;;;;;	  	  	  	  	 s$   A A A$#A$=BBB)
rX   rY   rZ   r   rm   r   
contextlibcontextmanagerr   r   r   s   @r!   r   r      sk        L    6 6 6(              r#   r   c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	ExecutorShutdownTestc                     | j                                          |                     t          | j         j        t
          dd           d S )Nr   rt   )r   r   r   RuntimeErrorr   powrU   s    r!   test_run_after_shutdownz,ExecutorShutdownTest.test_run_after_shutdown%  sI       ,-.q!	% 	% 	% 	% 	%r#   c                    t          dd                    | j        j        t	          | dd                              \  }}}|                     |           |                     |                                d           d S )N-caK  if 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")
            rv    r~   context   apple)r   formatr~   rX   getattrassertFalser   striprV   rcouterrs       r!   test_interpreter_shutdownz.ExecutorShutdownTest.test_interpreter_shutdown+  s    ' / T%7%@&tUB77  9 9: :C" 	h/////r#   c                 *   t          dd                    | j        j        t	          | dd                              \  }}}|                     d|                                           |                     |                                d           d S )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()
            rv   r   r   z)RuntimeError: cannot schedule new futuress   runtime-error)	r   r   r~   rX   r   assertIndecoder   r   r   s       r!   &test_submit_after_interpreter_shutdownz;ExecutorShutdownTest.test_submit_after_interpreter_shutdownA  s    ' /& T%7%@&tUB77  9 9': :C. 	A3::<<PPP&677777r#   c                       fdt          d          D             } j                                         |D ]}|                                 d S )Nc                 Z    g | ]'}j                             t          j        d           (S rH   r   r   r3   r4   r   s     r!   r   z=ExecutorShutdownTest.test_hang_issue12364.<locals>.<listcomp>^  s-    GGGdm""4:s33GGGr#   2   )r   r   r   r   )rV   fsr    s   `  r!   test_hang_issue12364z)ExecutorShutdownTest.test_hang_issue12364]  s^    GGGGU2YYGGG    	 	AHHJJJJ	 	r#   c                      fdt          d          D             } j                            d           d |D             }                     t	          |          d           d |D             }|D ]Z}                     |                                d|j        	                                |	                                           [                     t	          |          d
           d S )Nc                 Z    g | ]'}j                             t          j        d           (S r  r  r   s     r!   r   z<ExecutorShutdownTest.test_cancel_futures.<locals>.<listcomp>e  s-    FFFqdm""4:r22FFFr#   r  T)cancel_futuresc                 :    g | ]}|                                 |S r*   	cancelledr   futs     r!   r   z<ExecutorShutdownTest.test_cancel_futures.<locals>.<listcomp>j  s%    :::S#--//:S:::r#      c                 :    g | ]}|                                 |S r*   r  r  s     r!   r   z<ExecutorShutdownTest.test_cancel_futures.<locals>.<listcomp>p  s%    ;;;#3==??;#;;;r#   zfut._state=)r=   r   )
r   r   r   assertGreaterlenr   doner   assertIsNoner   )rV   r  r  othersr  s   `    r!   test_cancel_futuresz(ExecutorShutdownTest.test_cancel_futuresc  s    FFFFE"IIFFFd333 ;:B:::	3y>>2...
 <;;;; 	/ 	/COOCHHJJ,<sz,<,<O===cmmoo....
 	3v;;*****r#   c                 V   | j         t          j        k    rt          j        d          t          dd                    | j         j        t          | dd                              \  }}}| 	                    |           | 
                    |                                d           dS )zshutdown(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)
            rv   Nr   r   )r~   r   r   unittestSkipTestr   r   rX   r   r   r   r   r   s       r!   test_hang_gh83386z&ExecutorShutdownTest.test_hang_gh83386z  s    
 !<<<#KM M M ( / T%7%@&tUD99  ; ;	< 	<C 	h/////r#   c                    t          t          d          st          j        d          d }i }t	          | dd          r|                                 |d<    | j        dddi|}|                    t                    	                                 t          j        t          j
        |          }	 t          j        d	           |                    t                                                     |                    d
           t          j        d           t          j        t          j
        |           dS # t          j        d           t          j        t          j
        |           w xY w)zshutdown(wait=True) doesn't hang when a future was submitted and
        quickly canceled right before shutdown.

        See https://github.com/python/cpython/issues/94440.
        alarmz1Tested platform does not support the alarm signalc                      t          d          )Nztimed out waiting for shutdownr   )_signum_frames     r!   timeoutz7ExecutorShutdownTest.test_hang_gh94440.<locals>.timeout  s    ?@@@r#   rv   Nry   rx      rt   Tr   r   r*   )r}   signalr  r  r   r   r~   r   intr   SIGALRMr  cancelr   )rV   r$  r0   r   old_handlers        r!   test_hang_gh94440z&ExecutorShutdownTest.test_hang_gh94440  s[    vw'' 	E#CE E E	A 	A 	A 4%% 	6#'#3#3#5#5F< %4%>>!>v>>##%%%mFNG<<	7LOOOOOC  '')))4(((LOOOM&.+66666 LOOOM&.+6666s   2AD= =5E2N)
rX   rY   rZ   r   r   r  r	  r  r  r+  r*   r#   r!   r   r   $  s}        % % %0 0 0,8 8 88  + + +.0 0 0,7 7 7 7 7r#   r   c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	ThreadPoolShutdownTestc                    d }t          j        d          }t          d          D ]}| j                            ||           |                     t          | j        j                  d           t          d          D ]}|                                 | j        	                                 | j        j        D ]}|
                                 d S )Nc                 .    |                                   d S r   acquirelocks    r!   acquire_lockzCThreadPoolShutdownTest.test_threads_terminate.<locals>.acquire_lock      LLNNNNNr#   r      )	threading	Semaphorer   r   r   r   r  _threadsreleaser   join)rV   r4  semir6   s        r!   test_threads_terminatez-ThreadPoolShutdownTest.test_threads_terminate  s    	 	 	 !!$$q 	4 	4AM  s3333T]344a888q 	 	AKKMMMM   ' 	 	AFFHHHH	 	r#   c                 8   t          j        d          5 }|}|                     t          |                    t
          t          dd                              g d           d d d            n# 1 swxY w Y   |j        D ]}|                                 d S )Nrt   rx   r   
rt      r6  r   r%  r   r%  r   r6  rB  )	r   r   r   listmapabsr   r9  r;  )rV   er   r6   s       r!   test_context_manager_shutdownz4ThreadPoolShutdownTest.test_context_manager_shutdown  s    'A666 	=!HT!%%U2q\\":":;;;;;= = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=
 " 	 	AFFHHHH	 	s   AA11A58A5c                     t          j        d          }|                    t          t	          dd                    }|j        }~|D ]}|                                 d S )Nrt   r@  r   )r   r   rD  rE  r   r9  r;  rV   r   resthreadsr6   s        r!   test_del_shutdownz(ThreadPoolShutdownTest.test_del_shutdown  sc    -!<<<ll3b!--# 	 	AFFHHHH	 	r#   c                     t          j        d          }|                    t          t	          dd                    }|j        }|                    d           |D ]}|                                 d S )Nrt   r@  r   Fr   )r   r   rD  rE  r   r9  r   r;  rI  s        r!   test_shutdown_no_waitz,ThreadPoolShutdownTest.test_shutdown_no_wait  sy     -!<<<ll3b!--#u%%% 	 	AFFHHHH	 	r#   c                 "   t          j        dd          }|                    t          t	          dd                     |j        }~t          j                     |D ]1}|                     |j	        d           |
                                 2d S )Nrt   SpecialPool)rx   thread_name_prefixr   z^SpecialPool_[0-4]$r   r   rD  rE  r   r9  r   
gc_collectassertRegexr   r;  rV   r   rK  r6   s       r!   test_thread_names_assignedz1ThreadPoolShutdownTest.test_thread_names_assigned  s    -m= = =S%A,,'''# 	 	AQV%;<<<FFHHHH	 	r#   c                     t          j        d          }|                    t          t	          dd                     |j        }~t          j                     |D ]1}|                     |j	        d           |
                                 2d S )Nrt   r@  r   zThreadPoolExecutor-\d+_[0-4]$rR  rU  s       r!   test_thread_names_defaultz0ThreadPoolShutdownTest.test_thread_names_default  s    -!<<<S%A,,'''# 	 	A QV%EFFFFFHHHH		 	r#   c                     t          dd          \  }}}|                     |           |                     |                                d           d S )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   r   r   r   r   s       r!   test_cancel_futures_wait_falsez5ThreadPoolShutdownTest.test_cancel_futures_wait_false  sZ     ( /  C 	h/////r#   N)
rX   rY   rZ   r>  rG  rL  rN  rV  rX  rZ  r*   r#   r!   r-  r-    s            E E EE E E
 
 
  0 0 0 0 0r#   r-  c                   &    e Zd Zd Zd Zd Zd ZdS )ProcessPoolShutdownTestc                 F   d }|                                  }|                    d          dk    r| j        }nd}|                    d          }t	          d          D ]}| j                            ||           |                     t          | j        j	                  |           t	          d          D ]}|
                                 | j        j	        }| j                                         |                                D ]}|                                 d S )Nc                 .    |                                   d S r   r0  r2  s    r!   r4  zFProcessPoolShutdownTest.test_processes_terminate.<locals>.acquire_lock  r5  r#   F
allow_noner   r6  r   )r   get_start_methodr   r8  r   r   r   r   r  
_processesr:  r   valuesr;  )rV   r4  ry   expected_num_processesr<  rf   	processesps           r!   test_processes_terminatez0ProcessPoolShutdownTest.test_processes_terminate  s/   	 	 	 %%''
&&%&88FBB%)%6""%&"""1%%q 	4 	4AM  s3333T]5668NOOOq 	 	AKKMMMMM,	   !!## 	 	AFFHHHH	 	r#   c                    t          j        d|                                           5 }|j        }|                     t          |                    t          t          dd                              g d           d d d            n# 1 swxY w Y   |	                                D ]}|
                                 d S )Nrt   rw   r   rA  )r   r   r   rb  r   rC  rD  rE  r   rc  r;  )rV   rF  re  rf  s       r!   rG  z5ProcessPoolShutdownTest.test_context_manager_shutdown"  s    ($*:*:*<*<> > > 	=ABIT!%%U2q\\":":;;;;;= = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= !!## 	 	AFFHHHH	 	s   AB		BBc                    t          j        d|                                           }|                    t          t          dd                    }|j        }|j        }|j        }|j        }~t          j
                     |                                 |                                D ]}|                                 |                                 d S )Nrt   rw   r   )r   r   r   rD  rE  r   _executor_manager_threadrb  _call_queuer   rS  r;  rc  join_thread)rV   r   rJ  executor_manager_threadre  
call_queuerf  s          r!   rL  z)ProcessPoolShutdownTest.test_del_shutdown,  s    .$*:*:*<*<> > >ll3b!--"*"C'	)
"*"C 	 $$&&&!!## 	 	AFFHHHH     r#   c                    t          j        d|                                           }|                    t          t          dd                    }|j        }|j        }|j        }|	                    d           |
                                 |                                D ]}|
                                 |                                 d S )Nrt   rw   r   Fr   )r   r   r   rD  rE  r   rb  rk  rj  r   r;  rc  rl  )rV   r   rJ  re  rn  rm  rf  s          r!   rN  z-ProcessPoolShutdownTest.test_shutdown_no_waitB  s     .$*:*:*<*<> > >ll3b!--'	)
"*"Cu%%% 	 $$&&&!!## 	 	AFFHHHH     r#   N)rX   rY   rZ   rg  rG  rL  rN  r*   r#   r!   r\  r\  
  sX          .  E E E,E E E E Er#   r\  )r   c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
	WaitTestsc                    | j                             t          j        d          }t	          j        ||gt          j                  \  }}|                     |h|           |                     t                      |           d S N      ?return_when)	r   r   r3   r4   r   r   ALL_COMPLETEDr   rc   )rV   r   r  not_dones       r!   
test_20369zWaitTests.test_20369`  sz    %%dj#66 vv&6(/(=? ? ?h&4((()))))r#   c                    | j                             t          dd          }| j                             t          j        d          }t          j        t          ||gt
          j                  \  }}| 	                    t          |g          |           | 	                    t          t          |g          |           d S )N   r   rt  ru  )r   r   r-   r3   r4   r   r   CANCELLED_FUTUREFIRST_COMPLETEDr   rc   )rV   future1future2r  rx  s        r!   test_first_completedzWaitTests.test_first_completedi  s    -&&sB22-&&tz377 !7G4$46 6 6h 	gY....8998DDDDDr#   c                 V   | j                             t          j        d          }t	          j        t          t          |gt          j                  \  }}| 	                    t          t          t          g          |           | 	                    t          |g          |           d S rs  )r   r   r3   r4   r   r   CANCELLED_AND_NOTIFIED_FUTURESUCCESSFUL_FUTUREr}  r   rc   rV   r~  finishedpendings       r!   +test_first_completed_some_already_completedz5WaitTests.test_first_completed_some_already_completedt  s    -&&tz377#L/1BGL$46 6 6' 	24EFGG	 	 	 	gY11111r#   c                    | j                             t          dd          }| j                             t          d          }| j                             t          j        d          }t          j        |||gt          j                  \  }}| 	                    t          ||g          |           | 	                    t          |g          |           d S )Nr   r{  rt  r6  ru  )r   r   r-   r7   r3   r4   r   r   FIRST_EXCEPTIONr   rc   )rV   r~  r  future3r  r  s         r!   test_first_exceptionzWaitTests.test_first_exception  s    -&&sAr22-&&<<-&&tz155#L'7+#35 5 5' 	gw/00(;;;gY11111r#   c                    | j                             t          dd          }| j                             t          j        d          }t          j        t          t          t          ||gt
          j
                  \  }}|                     t          t          t          |g          |           |                     t          t          |g          |           d S )Nr{  r   rt  ru  )r   r   divmodr3   r4   r   r   r  r|  r  r  r   rc   rV   r~  r  r  r  s        r!   *test_first_exception_some_already_completez4WaitTests.test_first_exception_some_already_complete  s    -&&vr155-&&tz377#L"!.'# $35 5 5' 	/;%' ( ()1	3 	3 	3 	.8997CCCCCr#   c                 >   | j                             t          j        d          }t	          j        t          |gt          j                  \  }}|                     t          t          g          |           |                     t          |g          |           d S )Nr   ru  )
r   r   r3   r4   r   r   EXCEPTION_FUTUREr  r   rc   r  s       r!   'test_first_exception_one_already_failedz1WaitTests.test_first_exception_one_already_failed  s    -&&tz155#L"G,$46 6 6' 	./00(;;;gY11111r#   c           	         | j                             t          dd          }| j                             t          dd          }t	          j        t          t          t          ||gt          j	                  \  }}| 
                    t          t          t          t          ||g          |           | 
                    t                      |           d S )Nr   r   r{  ru  )r   r   r  r-   r   r   r  r  r  rw  r   rc   r  s        r!   test_all_completedzWaitTests.test_all_completed  s    -&&vq!44-&&sAr22#L".!	
 $13 3 3' 	/;.%%	' ( ( *2		3 	3 	3
 	(((((r#   c                    | j                             t          dd          }| j                             t          j        d          }t          j        t          t          t          ||gdt
          j
                  \  }}|                     t          t          t          t          |g          |           |                     t          |g          |           d S )N      rt   )r$  rv  )r   r   r-   r3   r4   r   r   r  r  r  rw  r   rc   r  s        r!   test_timeoutzWaitTests.test_timeout  s    -&&sAq11-&&tz155#L.!"'# #13 3 3' 	;./%' ( ( *2	3 	3 	3 	gY11111r#   N)rX   rY   rZ   ry  r  r  r  r  r  r  r  r*   r#   r!   rq  rq  _  s        * * *	E 	E 	E
2 
2 
2
2 
2 
2D D D 2 2 2) ) )&2 2 2 2 2r#   rq  c                       e Zd Zd ZdS )ThreadPoolWaitTestsc                     t          j                    fdt          j                    }t          j        d           	  fdt          d          D             }                                 t          j        |t          j	                   t          j        |           d S # t          j        |           w xY w)Nc                  0                                       d S r   r   )r_   s   r!   future_funcz@ThreadPoolWaitTests.test_pending_calls_race.<locals>.future_func  s    JJLLLLLr#   gư>c                 D    h | ]}j                                       S r*   )r   r   )r   r=  r  rV   s     r!   	<setcomp>z>ThreadPoolWaitTests.test_pending_calls_race.<locals>.<setcomp>  s)    HHH$-&&{33HHHr#   d   ru  )
r7  r^   r:   getswitchintervalsetswitchintervalr   rc   r   r   rw  )rV   oldswitchintervalr  r_   r  s   `  @@r!   test_pending_calls_racez+ThreadPoolWaitTests.test_pending_calls_race  s     !!	 	 	 	 	133d###	5HHHHHU3ZZHHHBIIKKKL)>????!"344444C!"34444s   AB* *C N)rX   rY   rZ   r  r*   r#   r!   r  r    s#        5 5 5 5 5r#   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )AsCompletedTestsc           	      b   | j                             t          dd          }| j                             t          dd          }t          t	          j        t          t          t          ||g                    }| 	                    t          t          t          t          ||g          |           d S )Nr   r{  r  r  )
r   r   r-   rc   r   as_completedr  r  r  r   )rV   r~  r  	completeds       r!   test_no_timeoutz AsCompletedTests.test_no_timeout  s    -&&sAr22-&&sAq11,.!"'#$ $ % %	
 	.!"'#$ $
 	 	 	 	 	r#   c                    | j                             t          j        d          }t	                      }	 t          j        t          t          t          |gd          D ]}|
                    |           n# t
          j        $ r Y nw xY w|                     t	          t          t          t          g          |           d S )Nr   r   r$  )r   r   r3   r4   rc   r   r  r  r  r  addTimeoutErrorr   )rV   r~  completed_futuresr   s       r!   test_zero_timeoutz"AsCompletedTests.test_zero_timeout  s    -&&tz155EE		!.2%&    . . "%%f----. # 	 	 	D	 	;./1 2 2 +	, 	, 	, 	, 	,s   AA7 7B	B	c                     | j                             t          j        d          }d t	          j        t          j        |d                    D             }|                     t          |          d           d S )Nr   c                     g | ]}|S r*   r*   )r   r    s     r!   r   z;AsCompletedTests.test_duplicate_futures.<locals>.<listcomp>  s%     
 
 
A
 
 
r#   r6  r%  )
r   r   r3   r4   r   r  	itertoolsrepeatr   r  )rV   r~  r  s      r!   test_duplicate_futuresz'AsCompletedTests.test_duplicate_futures	  sw     -&&tz155
 
+I,<Wa,H,HII
 
 
	 	Y+++++r#   c                    d t          d          D             }|                    t          t                               |                    t          t          d                     |                     t          j                  5  t          j        |d          D ]\}|	                    |           t          j        |          }~t          j                     |                      |                       ]	 d d d            n# 1 swxY w Y   |d                             d           t          j        |          D ]y}|	                    |           t          j        |          }~t          j                     |                      |                       |r|d                             d           zd S )	Nc                 *    g | ]}t                      S r*   )r   )r   rf   s     r!   r   zGAsCompletedTests.test_free_reference_yielded_future.<locals>.<listcomp>  s    333Q333r#      r$   r&   r'   r   r  test)r   r   r"   r   r   r   r   r  r  removeweakrefrefr   rS  r  
set_result)rV   futures_listr   wrs       r!   "test_free_reference_yielded_futurez3AsCompletedTests.test_free_reference_yielded_future  s    43%((333M0FGGGHHHMDDDEEEw344 	( 	(!.|QGGG ( (##F+++[(("$$$!!""$$''''(	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	Q""6****<88 	3 	3F'''V$$B   bbdd### 3Q**6222	3 	3s   
A4DDDc                 >   t           t          t          t          g}|                     t
          j                  5 }t          t          j        |d                     d d d            n# 1 swxY w Y   | 	                    t          |j                  d           d S )Nr   r  z2 (of 4) futures unfinished)r  PENDING_FUTURERUNNING_FUTUREr  r   r   r  rC  r  r   strr   )rV   r  r   s      r!   "test_correct_timeout_exception_msgz3AsCompletedTests.test_correct_timeout_exception_msg,  s    5~&(9; w344 	@%lA>>>???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	R\**,IJJJJJs   $A**A.1A.N)rX   rY   rZ   r  r  r  r  r  r*   r#   r!   r  r    sd           , , ,&, , ,3 3 32K K K K Kr#   r  c                   ^    e Zd Zd Zd Zd Zd Zd Zd Ze	j
        d             Zd Zd	 Zd
S )ExecutorTestc                     | j                             t          dd          }|                     d|                                           d S )Nr   r     )r   r   r   r   r   rV   r   s     r!   test_submitzExecutorTest.test_submit<  s?    %%c1a00fmmoo.....r#   c                 |   | j                             t          dd          }|                     d|                                           | j                             t
          ddd          }|                     |                                ddddf           |                     t                    5  | j                             t
          d	           d d d            n# 1 swxY w Y   |                     t                    5  | j                             d
           d d d            d S # 1 swxY w Y   d S )Nr   r  )r,      r%  r6  )rV   fn)r%  )r  arg)r  )r   r   r-   r   r   r1   r   	TypeErrorr  s     r!   test_submit_keywordz ExecutorTest.test_submit_keyword@  s   %%c1%22V]]__---%%gqqQ%??4!11E1E*FGGGy)) 	4 	4M  G 333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4y)) 	( 	(M  Q '''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s$   5"C##C'*C'D11D58D5c                 f   |                      t          | j                            t          t          d          t          d                              t          t          t          t          d          t          d                                         |                      t          | j                            t          t          d          t          d          d                    t          t          t          t          d          t          d                                         d S )N
   r6  	chunksize)r   rC  r   rD  r   r   rU   s    r!   test_mapzExecutorTest.test_mapJ  s    T]&&sE"IIuRyyAABBSeBiir3344	6 	6 	6 	T]&&sE"IIuRyyA&NNOOSeBiir3344	6 	6 	6 	6 	6r#   c                 0   | j                             t          g dg d          }|                     |                                d           |                     |                                d           |                     t          |j                   d S )N)r%  r%  r%  r%  )r   r6  r   rt   )r   r%  )r   rD  r  r   __next__r   ZeroDivisionError)rV   r=  s     r!   test_map_exceptionzExecutorTest.test_map_exceptionS  s~    MflllLLLAAv...v...+QZ88888r#   c                    g }	 | j                             t          j        g dd          D ]}|                    |           	 |                     d           n# t          j        $ r Y nw xY w|                     d d g|           d S )N)r   r   r  rt   r  zexpected TimeoutError)	r   rD  r3   r4   r   r   r   r  r   )rV   resultsr=  s      r!   test_map_timeoutzExecutorTest.test_map_timeoutY  s    	/]&&tz'0yy/0 ' 2 2 " " q!!!!" II-.... # 	 	 	D	
 	$w/////s   AA A.-A.c                     | j                             t          dg| j        dz   z             | j                                          d S )Nr   r%  )r   rD  r  r   r   rU   s    r!   test_shutdown_race_issue12456z*ExecutorTest.test_shutdown_race_issue12456g  sE     	#sd&7!&;<===     r#   c                 &   t                      }t          j                    t          j        |fd          }| j                            |j                   ~                    t          j
                  }|                     |d           d S )Nc                 ,                                     S r   )rc   )objmy_object_collecteds    r!   <lambda>z7ExecutorTest.test_no_stale_references.<locals>.<lambda>u  s    #6#:#:#<#< r#   r  z-Stale reference not collected within timeout.)rS   r7  r^   r  r  r   r   rW   r   r   SHORT_TIMEOUTr   )rV   	my_objectmy_object_callback	collectedr  s       @r!   test_no_stale_referencesz%ExecutorTest.test_no_stale_referencesn  s     JJ	'o//$[<<<<> > 	Y0111',,W5J,KK		G	I 	I 	I 	I 	Ir#   c                     dD ]K}|                      t          d          5  |                     |           d d d            n# 1 swxY w Y   Ld S )N)r   z"max_workers must be greater than 0r@  )assertRaisesRegexrN   r~   )rV   numbers     r!   test_max_workers_negativez&ExecutorTest.test_max_workers_negative~  s     	7 	7F''
)12 2 7 7 ""v"6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s   AA	
A	c                     | j                             t          t          d                    D ]G}t	          j        |          }~t          j                     |                      |                       Hd S )Nr  )	r   rD  rg   r   r  r  r   rS  r  )rV   r  r  s      r!   test_free_referencez ExecutorTest.test_free_reference  st     =$$%6b		BB 	$ 	$CS!!B   bbdd####		$ 	$r#   N)rX   rY   rZ   r  r  r  r  r  r  r   cpython_onlyr  r  r  r*   r#   r!   r  r  9  s        / / /( ( (6 6 69 9 90 0 0! ! ! I I I7 7 7$ $ $ $ $r#   r  c                   t    e Zd Zd Zd Zd Zd Z ej         e	e
d          d          d             Zd Zd	S )
ThreadPoolExecutorTestc                     g fd}| j                             |t          d                     | j                             d           |                     t          d                     dS )zTests verifying issue 11777.c                 2                         |            d S r   )r   )nr  s    r!   record_finishedzRThreadPoolExecutorTest.test_map_submits_without_iteration.<locals>.record_finished  s    OOAr#   r  Tr   N)r   rD  r   r   assertCountEqual)rV   r  r  s     @r!   "test_map_submits_without_iterationz9ThreadPoolExecutorTest.test_map_submits_without_iteration  s|    	 	 	 	 	 	/599555D)))hb		22222r#   c                     |                                  }t          dt          j                    pddz             }|                     |j        |           d S )N    r%  rB  )r~   minos	cpu_countr   _max_workers)rV   r   expecteds      r!   test_default_workersz+ThreadPoolExecutorTest.test_default_workers  sQ    %%''rBLNN/a1455.99999r#   c                    |                      d          }d }t          j        d          }t          d|j        z            D ]}|                    ||           |                     t          |j                  |j                   t          d|j        z            D ]}|	                                 |
                    d           d S )NrB  c                 .    |                                   d S r   r0  r2  s    r!   r4  z<ThreadPoolExecutorTest.test_saturation.<locals>.acquire_lock  r5  r#   r      Tr   )r~   r7  r8  r   r  r   r   r  r9  r:  r   )rV   r   r4  r<  r=  s        r!   test_saturationz&ThreadPoolExecutorTest.test_saturation  s    %%a((	 	 	 !!$$rH1122 	/ 	/AOOL#....X.//1FGGGrH1122 	 	AKKMMMMt$$$$$r#   c                    |                                  }|                    t          dd                                           |                    t          dd                                           |                    t          dd                                           |                     t          |j                  d           |                    d	           d S )
Nr{  r   r  r  r6     r%  Tr   )r~   r   r-   r   r   r  r9  r   rV   r   s     r!   test_idle_thread_reusez-ThreadPoolExecutorTest.test_idle_thread_reuse  s    %%''R##**,,,Q""))+++Q##**,,,X.//333t$$$$$r#   register_at_forkzneed os.register_at_forkc                 r   fdt          j        d          5 }|                    |           t          d          D ]\}t          j        dt          j        d                    5 }|                    t                     d d d            n# 1 swxY w Y   ]	 d d d            d S # 1 swxY w Y   d S )Nc                 4    |                      |            d S r   )r   )poolr   s    r!   r   zEThreadPoolExecutorTest.test_hang_global_shutdown_lock.<locals>.submit  s    KK%%%%%r#   r%  r  r   )ry   )r   r   r   r   r   r   r   tuple)rV   r  rf   workersr   s       @r!   test_hang_global_shutdown_lockz5ThreadPoolExecutorTest.test_hang_global_shutdown_lock  sD   	& 	& 	& 	& 	& '** 	*dKK%%%2YY * *0r~f?U?UVVV *ZaNN5)))* * * * * * * * * * * * * * **	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s6   AB,+BB,BB,BB,,B03B0c                    t          j                    g fd}|                     d          5 }|                    |d          }	 t	          j        |                    |ddgd	                    5 }|                     t                    5  t          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   
                                 n# 
                                 w xY w|                                 d d d            n# 1 swxY w Y   |                     d
dg           d S )Nc                                          d| d           	                                                       d| d           d S #                      d| d           w xY w)Nzident=z startedz stopped)r   r   )identlog
stop_events    r!   
log_n_waitzRThreadPoolExecutorTest.test_executor_map_current_future_cancel.<locals>.log_n_wait  s~    JJ*%***+++0!!!

.e.../////

.e...////s   A A&r%  r@  first)r  secondthirdr   r  zident='first' startedzident='first' stopped)r7  r^   r~   r   r   closingrD  r   r  nextrc   r   assertListEqual)rV   r  r  r  genr  r  s        @@r!   'test_executor_map_current_future_cancelz>ThreadPoolExecutorTest.test_executor_map_current_future_cancel  s
   _&&
	0 	0 	0 	0 	0 	0 A.. 	$++j+88C!'HHZ(G)<aHHH  "**<88 " "S			" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "     
    JJLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	S#:<S"TUUUUUsq   D ,C'9CB0$C0B44C7B48C;C'C	C'C	C'D 'C==D  D$'D$N)rX   rY   rZ   r  r  r  r	  r  
skipUnlessr}   r  r  r  r*   r#   r!   r  r    s        3 3 3: : :
% % %% % % X%788:TUU* * VU*V V V V Vr#   r  c                       e Zd Z ej        ej        dk    d          d             Zd Zd Z	e
d             Zd Z ej        d          d	             Zd
 Zd Zd Zd Zd Zd ZdS )ProcessPoolExecutorTestr   zWindows-only process limitc                     |                      t          d          5  t          j        d           d d d            d S # 1 swxY w Y   d S )Nzmax_workers must be <= 61>   r@  )r  rN   r   r   rU   s    r!   test_max_workers_too_largez2ProcessPoolExecutorTest.test_max_workers_too_large  s    ##J$?A A 	8 	8'B7777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   ?AAc                    | j                             t          j        d          g}t	          t          | j         j                                                            }|                                 |D ]"}| 	                    t          |j                   #| 	                    t          | j         j        t          dd           d S )Nr6  r   r  )r   r   r3   r4   r  iterrb  rc  	terminater   r   r   r   )rV   r   rf  r  s       r!   test_killed_childz)ProcessPoolExecutorTest.test_killed_child  s     =''
A667dm.55778899	 	= 	=C/<<<<+T]-A31MMMMMr#   c                      fd}t          t          t          t          d          t          d                              }                     t           j                            t          t          d          t          d          d                    |                                t           j                            t          t          d          t          d          d                    |                                t           j                            t          t          d          t          d          d                    |                                t          |           d S )Nc            	          t           j                            t          t	          d          t	          d          d                     d S )N(   r  r  )rC  r   rD  r   r   rU   s   r!   bad_mapz;ProcessPoolExecutorTest.test_map_chunksize.<locals>.bad_map  s<    ""3b		599"KKLLLLLr#   r+  r  r  r  )rC  rD  r   r   r   r   r   rN   )rV   r,  r  s   `  r!   test_map_chunksizez*ProcessPoolExecutorTest.test_map_chunksize  sK   	M 	M 	M 	M 	M 3sE"IIuRyy1122""3b		599"JJKK	 	 	 	""3b		599"KKLL	 	 	 	""3b		599"KKLL	 	 	 	*g.....r#   c                      t          d          )N{   r!  r   s    r!   _test_tracebackz'ProcessPoolExecutorTest._test_traceback  s    3r#   c                    | j                             | j                  }|                     t                    5 }|                                 d d d            n# 1 swxY w Y   |j        }|                     t          |          t                     | 
                    |j        d           |j        }|                     t          |          t          j        j                   |                     d|j                   t%          j                    5 }	 |# t          $ r" t)          j        t)          j                      Y nw xY w	 d d d            n# 1 swxY w Y   |                     d|                                           d S )N)r/  z&raise RuntimeError(123) # some comment)r   r   r1  r   r5   r   r   assertIsr   r   r   r/   	__cause__r   process_RemoteTracebackr   tbr   captured_stderrr:   
excepthookexc_infogetvalue)rV   r   r   exccausef1s         r!   test_tracebackz&ProcessPoolExecutorTest.test_traceback  s    %%d&:;;y)) 	RMMOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ld3ii...6***d5kk7?#CDDD>III$&& 	0"0	 0 0 0////0/		0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
 	>kkmm	% 	% 	% 	% 	%sA   AA"AED)EEEEEEmd5c                    |                                                                  }t          |          }| j                            t
          |          }|                                 |                     |j        	                    d                     d }t          j                     |                                 |                                 d S )Nr%  r  )r   Managerr\   r   r   idr   r   r_   r   r   rS  r   r;  )rV   r`   r  r   s       r!   test_ressources_gced_in_workersz7ProcessPoolExecutorTest.test_ressources_gced_in_workers  s       ((**C  %%b#..	q11222 




r#   c                 x   | j         }|                                 }|                    d          }d|j        z  }t	          |          D ]}|                    |j                   |                     t          |j	                  |j                   t	          |          D ]}|
                                 d S )Nr   r  )r   r   r8  r  r   r   r1  r   r  rb  r:  )rV   r   ry   r<  	job_countrf   s         r!   r  z'ProcessPoolExecutorTest.test_saturation/  s    =%%''
""1%%..	y!! 	) 	)AOOCK((((X01183HIIIy!! 	 	AKKMMMM	 	r#   c                    | j         }|                                                     d          dk    rt          j        d          |                    t          dd                                           |                    t          dd                                           |                    t          d	d
                                           |                     t          |j
                  d           d S )NFr_  r   (Incompatible with the fork start method.r{  r   r  r  r6  r  r%  )r   r   ra  r  r  r   r-   r   r   r  rb  r  s     r!   test_idle_process_reuse_onez3ProcessPoolExecutorTest.test_idle_process_reuse_one:  s    =..%.@@FJJ#$NOOOR##**,,,Q""))+++Q##**,,,X011155555r#   c                    | j         }|                                                     d          dk    rt          j        d          |                    t          dd                                           |                    t          dd           |                    t          dd	                                           |                    t          d
d           |                    t          dd                                           |                    t          dd           |                     t          |j
                  d           |                                 d S )NFr_  r   rH     r  !               r%  r   r   	   r6  )r   r   ra  r  r  r   r-   r   assertLessEqualr  rb  r   r  s     r!    test_idle_process_reuse_multiplez8ProcessPoolExecutorTest.test_idle_process_reuse_multipleD  s$   =..%.@@FJJ#$NOOOR##**,,,R$$$R$$++---R$$$Q""))+++Q"""S!455q999r#   c                    |                                  }|                    d          dk    rL|                     t                    5  |                     d|d           d d d            n# 1 swxY w Y   d S |                     d|d          }|                    t          j                  }|                                }|                    t          j                  }| 	                    |                                |           | 	                    t          |j                  d           |                    t          j                  }| 	                    |                                |           |                    t          j                  }|                                }|                     ||           | 	                    t          |j                  d           |                                 d S )NFr_  r   r%  r6  ry   max_tasks_per_child)r   ra  r   rN   r~   r   r  getpidr   r   r  rb  assertNotEqualr   )	rV   r   r   r>  original_pidf2f3f4new_pids	            r!   test_max_tasks_per_childz0ProcessPoolExecutorTest.test_max_tasks_per_childR  s    ""$$##u#55??"":.. Q Q""1a"PPPQ Q Q Q Q Q Q Q Q Q Q Q Q Q QF %%g1 & > >__RY''yy{{__RY''l333X0111555__RY''l333 __RY''))++L'222X0111555s   	A..A25A2c                     |                      dd          }|                     |j                                        d           d S )Nr%  r6  )rV  r   )r~   r   _mp_contextra  r  s     r!   2test_max_tasks_per_child_defaults_to_spawn_contextzJProcessPoolExecutorTest.test_max_tasks_per_child_defaults_to_spawn_contextn  sG     %%aQ%??->>@@'JJJJJr#   c                    |                                  }|                    d          dk    rt          j        d          |                     d|d          }g }t          d          D ],} |j        |                    t          ||                     -|	                                 t          |          D ];\  }}|                     |                                t          ||                     <d S )	NFr_  r   rH  r6  r%  rU  r  )r   ra  r  r  r~   r   r   r   r-   r   	enumerater   r   )rV   r   r   r   r=  r   s         r!   test_max_tasks_early_shutdownz5ProcessPoolExecutorTest.test_max_tasks_early_shutdownt  s   ""$$##u#55??#$NOOO %%g1 & > >q 	7 	7AGN8??31556666"7++ 	9 	9IAvV]]__c!Qii8888	9 	9r#   N)rX   rY   rZ   r  r  r:   r   r$  r(  r-  classmethodr1  r?  r   requires_hashdigestrD  r  rI  rS  r^  ra  rd  r*   r#   r!   r!  r!    s       Xw.0LMM8 8 NM8

N 
N 
N/ / /      [ % % %, (^'..  /.$	 	 	6 6 6    8K K K9 9 9 9 9r#   r!  c                     | rt          j        |            ddl}|                                 |                                 dS )zInduces a segfault.r   N)r3   r4   faulthandlerdisable_sigsegv)delayrh  s     r!   _crashrl    sP     
5r#   c                 "    t                       dS )z,Induces a segfault with dummy data in input.Nrl  )datas    r!   _crash_with_datarp    s    
HHHHHr#   c                  .    t          j        d           dS )z#Induces a sys exit with exitcode 1.r%  N)r:   exitr*   r#   r!   _exitrs    s    HQKKKKKr#   c                      |             )z-Function that raises an Exception in process.r*   )Errs    r!   _raise_errorrv    s    
#%%Kr#   c                 Z    ddl }|                                t          _         |             )z@Function that raises an Exception in process and ignores stderr.r   N)ioStringIOr:   stderr)ru  rx  s     r!   _raise_error_ignore_stderrr{    s%    IIICJ
#%%Kr#   c                      |             S )z(Function that returns a instance of cls.r*   r0  s    r!   _return_instancer}    s    355Lr#   c                       e Zd ZdZd ZdS )CrashAtPicklez5Bad object that triggers a segfault at pickling time.c                 "    t                       d S r   rn  rU   s    r!   
__reduce__zCrashAtPickle.__reduce__  s    r#   NrX   rY   rZ   __doc__r  r*   r#   r!   r  r    s)        ??    r#   r  c                       e Zd ZdZd ZdS )CrashAtUnpicklez7Bad object that triggers a segfault at unpickling time.c                     t           dfS Nr*   rn  rU   s    r!   r  zCrashAtUnpickle.__reduce__  s    rzr#   Nr  r*   r#   r!   r  r    s)        AA    r#   r  c                       e Zd ZdZd ZdS )ExitAtPicklez9Bad object that triggers a process exit at pickling time.c                 "    t                       d S r   rs  rU   s    r!   r  zExitAtPickle.__reduce__  s    r#   Nr  r*   r#   r!   r  r    s)        CC    r#   r  c                       e Zd ZdZd ZdS )ExitAtUnpicklez;Bad object that triggers a process exit at unpickling time.c                     t           dfS r  r  rU   s    r!   r  zExitAtUnpickle.__reduce__  s    byr#   Nr  r*   r#   r!   r  r    s)        EE    r#   r  c                       e Zd ZdZd ZdS )ErrorAtPicklez3Bad object that triggers an error at pickling time.c                 $    ddl m}  |d          )Nr   r
   zError in pickle)pickler   )rV   r   s     r!   r  zErrorAtPickle.__reduce__  s%    ((((((m-...r#   Nr  r*   r#   r!   r  r    s)        ==/ / / / /r#   r  c                       e Zd ZdZd ZdS )ErrorAtUnpicklez5Bad object that triggers an error at unpickling time.c                 "    ddl m} t          |ffS )Nr   )UnpicklingError)r  r  r{  )rV   r  s     r!   r  zErrorAtUnpickle.__reduce__  s"    ******)O+>>>r#   Nr  r*   r#   r!   r  r    s)        ??? ? ? ? ?r#   r  c                       e Zd Zej        Zd ZdddZd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )ExecutorDeadlockTestc                    dd l }ddlm}  |d          5 }|                    |           |                    d           |                                }d d d            n# 1 swxY w Y   |j                                        D ]}|                                 |	                    d           t          d| t          j                   |                     d	|            d S )
Nr   )TemporaryFilezw+)mode)fileTr   z
Traceback:
 zExecutor deadlock:

)rh  tempfiler  dump_tracebackseekreadrb  rc  r'  r   r9   r:   
__stderr__r   )rV   r   rh  r  r    r7  rf  s          r!   _fail_on_deadlockz&ExecutorDeadlockTest._fail_on_deadlock  sA    	******]%%% 	''Q'///FF1IIIB	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 $++-- 	 	AKKMMMM 	t$$$$$$3>::::		/2//00000s   A A##A'*A'Fignore_stderrc                D   | j                             d           |                     d|                                           } |j        |g|R  }|rt          j                    }nt          j                    }	 | 	                    |          5  |5  |
                    | j                   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   n*# t          j        $ r |                     |           Y nw xY w|                    d           d S )NTr   r   rw   r  )r   r   r~   r   r   r   r8  r   nullcontextr   r   TIMEOUTr   r  r  )rV   errorfuncr  r/   r   rJ  r   s           r!   _check_crashz!ExecutorDeadlockTest._check_crash  s   D)))%%d&6&6&8&8 & : :hod*T*** 	*(**BB'))B	-""5)) 5 5 5 5JJt|J4445 5 5 5 5 5 5 5 5 5 5 5 5 5 55 5 5 5 5 5 5 5 5 5 5 5 5 5 5 # 	- 	- 	- ""8,,,,,	- 	t$$$$$sZ   =C  CB=1C=C	CC	CC  CC  CC   $DDc                 `    |                      t          t          t                                 d S r   )r  r   rC  r  rU   s    r!   test_error_at_task_picklez.ExecutorDeadlockTest.test_error_at_task_pickle   s&     	-]__=====r#   c                 `    |                      t          t          t                                 d S r   )r  r   rC  r  rU   s    r!   test_exit_at_task_unpicklez/ExecutorDeadlockTest.test_exit_at_task_unpickle  s'    +R1A1ABBBBBr#   c                 `    |                      t          t          t                                 d S r   )r  r   rC  r  rU   s    r!   test_error_at_task_unpicklez0ExecutorDeadlockTest.test_error_at_task_unpickle	  '    +R1B1BCCCCCr#   c                 `    |                      t          t          t                                 d S r   )r  r   rC  r  rU   s    r!   test_crash_at_task_unpicklez0ExecutorDeadlockTest.test_crash_at_task_unpickle  r  r#   c                 F    |                      t          t                     d S r   )r  r   rl  rU   s    r!   %test_crash_during_func_exec_on_workerz:ExecutorDeadlockTest.test_crash_during_func_exec_on_worker  s    +V44444r#   c                 F    |                      t          t                     d S r   )r  
SystemExitrs  rU   s    r!   $test_exit_during_func_exec_on_workerz9ExecutorDeadlockTest.test_exit_during_func_exec_on_worker  s    *e,,,,,r#   c                 R    |                      t          t          t                     d S r   )r  r   rv  rU   s    r!   %test_error_during_func_exec_on_workerz:ExecutorDeadlockTest.test_error_during_func_exec_on_worker  s     ,lCCCCCr#   c                 R    |                      t          t          t                     d S r   )r  r   r}  r  rU   s    r!   )test_crash_during_result_pickle_on_workerz>ExecutorDeadlockTest.test_crash_during_result_pickle_on_worker  s$     	+-=}MMMMMr#   c                 R    |                      t          t          t                     d S r   )r  r  r}  r  rU   s    r!   (test_exit_during_result_pickle_on_workerz=ExecutorDeadlockTest.test_exit_during_result_pickle_on_worker"  s#     	*&6EEEEEr#   c                 R    |                      t          t          t                     d S r   )r  r   r}  r  rU   s    r!   )test_error_during_result_pickle_on_workerz>ExecutorDeadlockTest.test_error_during_result_pickle_on_worker'  s#     	-)9=IIIIIr#   c                 V    |                      t          t          t          d           d S )NTr  )r  r   r}  r  rU   s    r!   3test_error_during_result_unpickle_in_result_handlerzHExecutorDeadlockTest.test_error_during_result_unpickle_in_result_handler,  s6     	+*O(, 	 	. 	. 	. 	. 	.r#   c                 R    |                      t          t          t                     d S r   )r  r   r}  r  rU   s    r!   2test_exit_during_result_unpickle_in_result_handlerzGExecutorDeadlockTest.test_exit_during_result_unpickle_in_result_handler3  s$     	+-=~NNNNNr#   c                    | j                             d           |                     d|                                           5 }|| _         |                    t
          d          }|                    d           |                     t                    5  |                                 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NTr   r   rw   rH   )rk  )	r   r   r~   r   r   rl  r   r   r   )rV   r   r    s      r!   test_shutdown_deadlockz+ExecutorDeadlockTest.test_shutdown_deadlock8  sU    	D)))A+/+;+;+=+=   ? ? 	BJ$DMb11A4(((""#455  


              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s7   ACB:.C:B>	>CB>	CCCc                 b   | j                             d           |                     d|                                           5 }|| _         |                    t
          d                                           |j        }|                    t
          t                                }|                    d           | 	                    t                    5  |                                 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                                 d S )NTr   r   rw   r&   F)r   r   r~   r   r   rC  r   rj  r  r   r   r;  )rV   r   executor_managerr    s       r!   test_shutdown_deadlock_picklez2ExecutorDeadlockTest.test_shutdown_deadlock_pickleD  s    	D)))A+/+;+;+=+=   ? ? 	BJ$DM
 OOB##**,,,'@ MOO44A5)))""=11  


              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	& 	s7   BDC9-D9C=	=D C=	DDDc           	         | j                             d           dt          j        z  }|                     d|                                           5 }|| _         |                     t                    5  t          |	                    t          |gdz                       d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NTr   ar   rw   r  )r   r   r   PIPE_MAX_SIZEr~   r   r   r   rC  rD  rp  )rV   ro  r   s      r!   test_crash_big_dataz(ExecutorDeadlockTest.test_crash_big_data^  sp   
 	D)))W**A+/+;+;+=+=   ? ? 	BBJ$DM""#455 B BX\\"2TFRK@@AAAB B B B B B B B B B B B B B B	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs6   "C6-B/#C/B3	3C6B3	7CCCN)rX   rY   rZ   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r*   r#   r!   r  r    sH       #G1 1 1& >C % % % % %.> > >
C C CD D DD D D5 5 5- - -D D DN N N
F F F
J J J
. . .O O O

 
 
     4B B B B Br#   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )FutureTestsc                     d fd}t                      }|                    |           |                    d           |                     d           d S )Nc                 0    |                                  d S r   r   callback_futurecallback_results    r!   r  z6FutureTests.test_done_callback_with_result.<locals>.fnu      -4466OOOr#   rt   )r   add_done_callbackr  r   rV   r  r    r  s      @r!   test_done_callback_with_resultz*FutureTests.test_done_callback_with_results  sk    	7 	7 	7 	7 	7 HH	B	QO,,,,,r#   c                     d fd}t                      }|                    |           |                    t          d                     |                     dj                   d S )Nc                 0    |                                  d S r   r   r  callback_exceptions    r!   r  z9FutureTests.test_done_callback_with_exception.<locals>.fn      !0!:!:!<!<r#   r  r  )r   r  set_exceptionr5   r   r/   rV   r  r    r  s      @r!   !test_done_callback_with_exceptionz-FutureTests.test_done_callback_with_exception~  s{    !	= 	= 	= 	= 	= HH	B		&))***$6$;<<<<<r#   c                     d fd}t                      }|                    |           |                     |                                           |                                d S )Nc                 0    |                                  d S r   r  r  was_cancelleds    r!   r  z6FutureTests.test_done_callback_with_cancel.<locals>.fn      +5577MMMr#   )r   r  r   r)  rV   r  r    r  s      @r!   test_done_callback_with_cancelz*FutureTests.test_done_callback_with_cancel  sr    	8 	8 	8 	8 	8 HH	B

###&&&&&r#   c                    t          j                    5 }ddfd}fd}t                      }|                    |           |                    |           |                    d           |                                |                                |                     d|                                           d d d            d S # 1 swxY w Y   d S )NFc                 &    dt          d          )NTdoh!r5   )r  raising_was_calleds    r!   
raising_fnz9FutureTests.test_done_callback_raises.<locals>.raising_fn  s    %)"'''r#   c                     dd S )NTr*   )r  fn_was_calleds    r!   r  z1FutureTests.test_done_callback_raises.<locals>.fn  s     $r#   rt   zException: doh!)r   r8  r   r  r  r   r   r;  )rV   rz  r  r  r    r  r  s        @@r!   test_done_callback_raisesz%FutureTests.test_done_callback_raises  sJ   $&& 	@&!&!M( ( ( ( (
% % % % % A
+++###LLOOOOO.///OOM***MM+V__->->???'	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   B.CCCc                     d fd}t                      }|                    d           |                    |           |                     d           d S )Nc                 0    |                                  d S r   r  r  s    r!   r  z=FutureTests.test_done_callback_already_successful.<locals>.fn  r  r#   rt   )r   r  r  r   r  s      @r!   %test_done_callback_already_successfulz1FutureTests.test_done_callback_already_successful  sk    	7 	7 	7 	7 	7 HH	Q	BO,,,,,r#   c                     d fd}t                      }|                    t          d                     |                    |           |                     dj                   d S )Nc                 0    |                                  d S r   r  r  s    r!   r  z9FutureTests.test_done_callback_already_failed.<locals>.fn  r  r#   r  r  )r   r  r5   r  r   r/   r  s      @r!   !test_done_callback_already_failedz-FutureTests.test_done_callback_already_failed  s{    !	= 	= 	= 	= 	= HH		&))***	B$6$;<<<<<r#   c                     d fd}t                      }|                     |                                           |                    |           |                                d S )Nc                 0    |                                  d S r   r  r  s    r!   r  z<FutureTests.test_done_callback_already_cancelled.<locals>.fn  r  r#   )r   r   r)  r  r  s      @r!   $test_done_callback_already_cancelledz0FutureTests.test_done_callback_already_cancelled  sr    	8 	8 	8 	8 	8 HH

###	B&&&&&r#   c                 t   t          j                    5 }d }t                      }|                    d           |                    |           |                     d|                                           |                     d|                                           d d d            d S # 1 swxY w Y   d S )Nc                      t          d          )Nr  r  )r  s    r!   r  zKFutureTests.test_done_callback_raises_already_succeeded.<locals>.raising_fn  s    '''r#   rt   zexception calling callback forr  )r   r8  r   r  r  r   r;  )rV   rz  r  r    s       r!   +test_done_callback_raises_already_succeededz7FutureTests.test_done_callback_raises_already_succeeded  s    $&& 	5&( ( ( A LLOOO
+++MM:FOO<M<MNNNMM&&//"3"3444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   BB--B14B1c                    |                      t          t                    d           |                      t          t                    d           |                      t          t                    d           |                      t          t
                    d           |                      t          t                    d           |                      t          t                    d           d S )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>)rT  reprr  r  r|  r  r  r  rU   s    r!   	test_reprzFutureTests.test_repr  s   n--@	B 	B 	Bn--@	B 	B 	B.//B	D 	D 	D;<<B	D 	D 	D%&&G	I 	I 	I 	&''E	G 	G 	G 	G 	Gr#   c                 r   t          t                    }t          t                    }t          t                    }t          t                    }t          t
          t                                }t          t
          d          }|                     |                                           | 	                    |j
        t                     |                     |                                           | 	                    |j
        t                     |                     |                                           | 	                    |j
        t                     |                     |                                           | 	                    |j
        t                     |                     |                                           | 	                    |j
        t
                     |                     |                                           | 	                    |j
        t
                     d S )Nr$   r%   rt   r'   )r"   r   r   r   r   r   OSErrorr   r)  r   r   r   )rV   r>  rZ  r[  r\  f5f6s          r!   test_cancelzFutureTests.test_cancel  s   ))))))+++!7888WYY???!444		$$$I...%%%G,,,		$$$I...		$$$$:;;;%%%H---%%%H-----r#   c                    |                      t                                                     |                      t                                                     |                     t
                                                     |                     t                                                     |                      t                                                     |                      t                                                     d S r   )	r   r  r  r  r   r|  r  r  r  rU   s    r!   test_cancelledzFutureTests.test_cancelled  s    11334441133444(22445555??AABBB)3355666*446677777r#   c                    |                      t                                                     |                      t                                                     |                     t
                                                     |                     t                                                     |                     t                                                     |                     t                                                     d S r   )	r   r  r  r  r   r|  r  r  r  rU   s    r!   	test_donezFutureTests.test_done  s    ,,..///,,..///(--//0005::<<===(--//000)..0011111r#   c                    |                      t                                                     |                     t                                                     |                      t
                                                     |                      t                                                     |                      t                                                     |                      t                                                     d S r   )	r   r  runningr   r  r|  r  r  r  rU   s    r!   test_runningzFutureTests.test_running  s    //11222..00111)11334446>>@@AAA)1133444*224455555r#   c                    |                      t          j        t          j        d           |                      t          j        t
          j        d           |                      t          j        t          j        d           |                      t          j        t          j        d           |                      t          t          j        d           |                     t                              d          d           d S )Nr   r  r&   )r   r   r  r  r   r  CancelledErrorr|  r  r  r  r   r  rU   s    r!   test_result_with_timeoutz$FutureTests.test_result_with_timeout  s    '.(/ 	 	< 	< 	<'.(/ 	 	< 	< 	<'0*11 	 	> 	> 	>'07> 	 	K 	K 	K'#3#:AFFF*11!1<<bAAAAAr#   c                 
   fd}t          t                    t          j        |          }|                                 |                                         d          d           |                                 d S )Nc                  Z    t          j        d                                d           d S )Nr%  r&   )r3   r4   r  r>  s   r!   notificationz:FutureTests.test_result_with_success.<locals>.notification,  s(    JqMMMMM"r#   r$   targetrt   r  r&   )r"   r   r7  Threadstartr   r   r;  rV   r  r6   r>  s      @r!   test_result_with_successz$FutureTests.test_result_with_success*  s    	 	 	 	 	
 )))L111				1--r222	r#   c                    fd}t          t                    t          j        |          }|                                 |                     t          j        j        t          j
                   |                                 d S )Nc                  X    t          j        d                                             d S Nr%  )r3   r4   r)  r  s   r!   r  z9FutureTests.test_result_with_cancel.<locals>.notification:  s!    JqMMMIIKKKKKr#   r$   r  r  )r"   r   r7  r  r  r   r   r  r   r   r  r;  r  s      @r!   test_result_with_cancelz#FutureTests.test_result_with_cancel8  s    	 	 	 	 	
 )))L111				'0)W-B 	 	D 	D 	D	r#   c                 F   |                      t          j        t          j        d           |                      t          j        t
          j        d           |                      t          j        t          j        d           |                      t          j        t          j        d           | 	                    t          t                              d          t                               |                     t                              d          d            d S )Nr   r  )r   r   r  r  r   r  r  r|  r  r   
isinstancer  r  r   r  rU   s    r!   test_exception_with_timeoutz'FutureTests.test_exception_with_timeoutG  s   '.(2A 	 	? 	? 	?'.(2A 	 	? 	? 	?'0*4a 	 	A 	A 	A'07A1 	 	N 	N 	N
#3#=#=a#=#H#H#*, , 	- 	- 	-*44Q4??FFFFFr#   c                 B   fd}t          t                    t          j        |          }|                                 |                     t                              t          j	                  t                               |                                 d S )Nc                      t          j        d            j        5  t           _        t                       _         j                                         d d d            d S # 1 swxY w Y   d S r  )r3   r4   
_conditionr   r   r  r   
notify_allr  s   r!   r  z=FutureTests.test_exception_with_success.<locals>.notificationU  s    JqMMM + +$	 '		((***+ + + + + + + + + + + + + + + + + +s   9A##A'*A'r$   r  r  )r"   r   r7  r  r  r   r!  r   r   r  r  r;  r  s      @r!   test_exception_with_successz'FutureTests.test_exception_with_successT  s    	+ 	+ 	+ 	+ 	+ )))L111				
2<<8M<#N#NPWXXYYY	r#   c                    t          t                    }|                    d           |                     t          j        d          5  |                    d           d d d            n# 1 swxY w Y   |                     |                                           |                     |	                                d           d S )Nr$   r%  z=FINISHED: <Future at 0x[0-9a-f]+ state=finished returned int>r   )
r"   r   r  r  r   InvalidStateErrorr   r  r   r   )rV   r    s     r!   test_multiple_set_resultz$FutureTests.test_multiple_set_resultd  s    (((	Q##)/
 
 	 	
 LLOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	!!!Q'''''s   A--A14A1c                 x   t          t                    }t                      }|                    |           |                     t
          j        d          5  |                    t                                 d d d            n# 1 swxY w Y   |                     |	                                |           d S )Nr$   zBFINISHED: <Future at 0x[0-9a-f]+ state=finished raised ValueError>)
r"   r   rN   r  r  r   r)  r5   r   r   )rV   r    rF  s      r!   test_multiple_set_exceptionz'FutureTests.test_multiple_set_exceptionr  s    (((LL	##)4
 
 	) 	)
 OOIKK(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	*****s   "BBBN)rX   rY   rZ   r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r"  r'  r*  r,  r*   r#   r!   r  r  r  sL       	- 	- 	-	= 	= 	=	' 	' 	'@ @ @,	- 	- 	-	= 	= 	=	' 	' 	'5 5 5 G G G". . .48 8 82 2 26 6 6
B 
B 
B    G G G   ( ( (+ + + + +r#   r  c                      t          j        t          j        j                   t          j                    } t          j        t
          j        g| R   d S r   )r  addModuleCleanupmultiprocessingutil_cleanup_testsr   rk   rp   )thread_infos    r!   setUpModuler3    sJ    o2ABBB"244K.@O;OOOOOOr#   __main__r   )cr  r   test.supportr   r   import_moduler   test.support.script_helperr   r   r  rI   logging.handlersr	   r  r   r&  r:   r7  r3   r  r  r  r   
concurrentr   concurrent.futures._baser   r   r   r   r   r   r   concurrent.futures.processr   r   multiprocessing.processr/  multiprocessing.utilr   check_sanitizerr  r"   r  r  r|  r  r  r  r  rA   r-   r1   r7   r>   rB   rD   rQ   objectrS   r\   rg   TestCaseri   rs   r   r   r   r   r   r   r   r   r-  r\  rq  r  r  r  r  r!  rl  rp  rs  rv  r{  r}  r  r  r  r  r  r  r  r  r3  rX   mainr*   r#   r!   <module>rB     s	         & & & & & & ) ) ) ) ) )  . / / / ' ' ' ' ' ' 7 7 7 7 7 7          ) ) ) ) ) ) 				   



                                           O N N N N N N N             74555 @ (
>
?
??  4     W---W--- =y111  -4J K K K  =x7799EEE !M<<< $     , , ,  
    - - - -    v   
         > > > > >8$ > > >( ( ( ( ( ( ( (B/ / / / /m / / /% % % % %= % % %	% 	% 	% 	% 	%M 	% 	% 	%% % % % % % % % )5+:+?+E+@+B   (8 8 8 8 8} 8 8 8$5  5  5  5  5 m 5  5  5 p  & ' ' '  - . . .E7 E7 E7 E7 E7 E7 E7 E7P[0 [0 [0 [0 [0_.BL [0 [0 [0|LE LE LE LE LE2 LE LE LE^  -';'A'<'>? ? ? ?j2 j2 j2 j2 j2 j2 j2 j2Z5 5 5 5 5/9l 5 5 5$  i';'A'<'>? ? ? ?OK OK OK OK OK OK OK OKd  & ' ' 'S$ S$ S$ S$ S$ S$ S$ S$lLV LV LV LV LV_lL LV LV LV^c9 c9 c9 c9 c9l c9 c9 c9L  -';'A'<'>? ? ? ?
     
  
  
    
    F       f       6       V   / / / / /F / / /? ? ? ? ?f ? ? ?VB VB VB VB VB VB VB VBr  *';'A'<'>? ? ? ?L+ L+ L+ L+ L+, L+ L+ L+^P P P zHMOOOOO r#   