+
    Bi	1                        ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHtHt ^ RIHt ^RIHtHtHtHtHt RR ltR tR	 tR
 tR tR t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t  ! R R]4      t! ! R R]4      t" ! R R4      t#]! ]$! 4       ]#]]]3R7       R t%]&R8X  d   ]PN                  ! 4        R# R# )    NPicklingError)futures)BrokenProcessPool_ThreadWakeup)support)create_executor_testssetup_moduleProcessPoolForkMixinProcessPoolForkserverMixinProcessPoolSpawnMixinc                     V '       d   \         P                  ! V 4       ^ RIpVP                  4        VP	                  4        R# r   N)timesleepfaulthandlerdisable_sigsegv)delayr   s   & A/usr/lib/python3.14/test/test_concurrent_futures/test_deadlock.py_crashr      s,    

5    c                     \        4        R # Nr   )datas   &r   _crash_with_datar      s    
Hr   c                  2    \         P                  ! ^4       R# )   N)sysexit r   r   _exitr#   !   s    HHQKr   c                     V ! 4       hr   r"   )Errs   &r   _raise_errorr&   &   s	    
%Kr   c                 J    ^ RI pVP                  4       \        n        V ! 4       hr   )ioStringIOr    stderr)r%   r(   s   & r   _raise_error_ignore_stderrr+   +   s    CJ
%Kr   c                     V ! 4       # r   r"   )clss   &r   _return_instancer.   2   s	    5Lr   c                   &   a  ] tR t^7t o R tRtV tR# )CrashAtPicklec                    \        4        R # r   r   selfs   &r   
__reduce__CrashAtPickle.__reduce__9   s    r   r"   N__name__
__module____qualname____firstlineno__r4   __static_attributes____classdictcell____classdict__s   @r   r0   r0   7   s      r   r0   c                   &   a  ] tR t^=t o R tRtV tR# )CrashAtUnpicklec                    \         R3# Nr"   r   r2   s   &r   r4   CrashAtUnpickle.__reduce__?   s    rzr   r"   Nr6   r=   s   @r   r@   r@   =   s      r   r@   c                   &   a  ] tR t^Ct o R tRtV tR# )ExitAtPicklec                    \        4        R # r   r#   r2   s   &r   r4   ExitAtPickle.__reduce__E   s    r   r"   Nr6   r=   s   @r   rE   rE   C   s      r   rE   c                   &   a  ] tR t^It o R tRtV tR# )ExitAtUnpicklec                    \         R3# rB   rG   r2   s   &r   r4   ExitAtUnpickle.__reduce__K   s    byr   r"   Nr6   r=   s   @r   rJ   rJ   I   s      r   rJ   c                   &   a  ] tR t^Ot o R tRtV tR# )ErrorAtPicklec                    ^ RI Hp V! R4      h)r   r   zError in pickle)pickler   )r3   r   s   & r   r4   ErrorAtPickle.__reduce__Q   s    (-..r   r"   Nr6   r=   s   @r   rN   rN   O   s     / /r   rN   c                   &   a  ] tR t^Vt o R tRtV tR# )ErrorAtUnpicklec                     ^ RI Hp \        V33# )r   )UnpicklingError)rP   rU   r+   )r3   rU   s   & r   r4   ErrorAtUnpickle.__reduce__X   s    *)O+>>>r   r"   Nr6   r=   s   @r   rS   rS   V   s     ? ?r   rS   c                     a  ] tR t^]t o ]P
                  tR tRR/R ltR t	R t
R t]P                  ! RR	R
7      R 4       t]P                  ! RR	R
7      R 4       tR tR t]P                  ! RR	R
7      R 4       tR tR tR tR t]P                  ! RR	R
7      R 4       tR t]P                  ! RR	R
7      R 4       tR tRtV tR# )ExecutorDeadlockTestc                   ^ RI p^ RIHp V! RR7      ;_uu_ 4       pVP                  VR7       VP	                  ^ 4       VP                  4       pRRR4       VP                  P                  4        F  pVP                  4        K  	  VP                  RR7       \        RX 2\        P                  R7       V P                  R	V 24       R#   + '       g   i     L; i)
r   N)TemporaryFilezw+)mode)fileTwaitz
Traceback:
 zExecutor deadlock:

)r   tempfilerZ   dump_tracebackseekread
_processesvalues	terminateshutdownprintr    
__stderr__fail)r3   executorr   rZ   ftbps   &&     r   _fail_on_deadlock&ExecutorDeadlockTest._fail_on_deadlock`   s     	*%%''Q'/FF1IB & $$++-AKKM . 	t$t$3>>:		*2$/0 &%s   4CC	ignore_stderrFc          	     z   V P                   P                  R R7       V P                  ^V P                  4       R7      pVP                  ! V.VO5!  pV'       d   \
        P                  ! 4       pM\        P                  ! 4       p V P                  V4      ;_uu_ 4        V;_uu_ 4        VP                  V P                  R7       RRR4       RRR4       TP                  R R7       R#   + '       g   i     L,; i  + '       g   i     L7; i  \        P                   d    T P                  T4        Lbi ; i)Tr]   max_workers
mp_context)timeoutN)rj   rf   executor_typeget_contextsubmitr   captured_stderr
contextlibnullcontextassertRaisesresultTIMEOUTr   TimeoutErrorrn   )r3   errorfuncrp   argsrj   rescms   &&&$*   r   _check_error!ExecutorDeadlockTest._check_errorr   s    D)%%d&6&6&8 & :ood*T*((*B'')B	-""5))RJJt||J4  * 	t$ R *) ## 	- ""8,	-sH   D C>*C+	C>D +C;6C>>D		D D &D:9D:c                L    V P                  \        \        \        4       4       R # r   )r   r   idrN   r2   s   &r   test_error_at_task_pickle.ExecutorDeadlockTest.test_error_at_task_pickle   s     	-]_=r   c                L    V P                  \        \        \        4       4       R # r   )r   r   r   rJ   r2   s   &r   test_exit_at_task_unpickle/ExecutorDeadlockTest.test_exit_at_task_unpickle   s    +R1ABr   c                    V P                  \        \        R \        P                  4       V P	                  \
        \        \        4       4       R# )r*   N)
addCleanupsetattrr    r*   r   r   r   rS   r2   s   &r   test_error_at_task_unpickle0ExecutorDeadlockTest.test_error_at_task_unpickle   s0    h

; 	+R1BCr   z"UBSan: explicit SIGSEV not allowedT)ubc                L    V P                  \        \        \        4       4       R # r   )r   r   r   r@   r2   s   &r   test_crash_at_task_unpickle0ExecutorDeadlockTest.test_crash_at_task_unpickle   s     	+R1BCr   c                :    V P                  \        \        4       R # r   )r   r   r   r2   s   &r   %test_crash_during_func_exec_on_worker:ExecutorDeadlockTest.test_crash_during_func_exec_on_worker   s     	+V4r   c                :    V P                  \        \        4       R # r   )r   
SystemExitr#   r2   s   &r   $test_exit_during_func_exec_on_worker9ExecutorDeadlockTest.test_exit_during_func_exec_on_worker   s    *e,r   c                D    V P                  \        \        \        4       R # r   )r   RuntimeErrorr&   r2   s   &r   %test_error_during_func_exec_on_worker:ExecutorDeadlockTest.test_error_during_func_exec_on_worker   s    ,lCr   c                D    V P                  \        \        \        4       R # r   )r   r   r.   r0   r2   s   &r   )test_crash_during_result_pickle_on_worker>ExecutorDeadlockTest.test_crash_during_result_pickle_on_worker   s     	+-=}Mr   c                D    V P                  \        \        \        4       R # r   )r   r   r.   rE   r2   s   &r   (test_exit_during_result_pickle_on_worker=ExecutorDeadlockTest.test_exit_during_result_pickle_on_worker   s     	*&6Er   c                D    V P                  \        \        \        4       R # r   )r   r   r.   rN   r2   s   &r   )test_error_during_result_pickle_on_worker>ExecutorDeadlockTest.test_error_during_result_pickle_on_worker   s     	-)9=Ir   c                    V P                  \        \        R \        P                  4       V P	                  \
        \        \        RR7       R# )r*   T)rp   N)r   r   r    r*   r   r   r.   rS   r2   s   &r   3test_error_during_result_unpickle_in_result_handlerHExecutorDeadlockTest.test_error_during_result_unpickle_in_result_handler   s8    h

; 	+*O(, 	 	.r   c                D    V P                  \        \        \        4       R # r   )r   r   r.   rJ   r2   s   &r   2test_exit_during_result_unpickle_in_result_handlerGExecutorDeadlockTest.test_exit_during_result_unpickle_in_result_handler   s     	+-=~Nr   c           	        V P                   P                  R R7       V P                  ^V P                  4       R7      ;_uu_ 4       pWn         VP	                  \
        RR7      pVP                  R R7       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)Tr]   rr   g?)r   N)	rj   rf   rv   rw   rx   r   r|   r   r}   )r3   rj   rk   s   &  r   test_shutdown_deadlock+ExecutorDeadlockTest.test_shutdown_deadlock   s     	D)A+/+;+;+=   ? ?BJ$Mb1A4(""#455
 6? ?
 65? ? ?s%   AC	B6	$C	6CC		C	c           	     F   V P                   P                  R R7       V P                  ^V P                  4       R7      ;_uu_ 4       pWn         VP	                  \
        ^*4      P                  4        VP                  pVP	                  \
        \        4       4      pVP                  RR7       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       RRR4       XP                  4        R#   + '       g   i     L*; i  + '       g   i     L5; i)Tr]   rr   FN)rj   rf   rv   rw   rx   r   r}   _executor_manager_threadrN   r|   r   join)r3   rj   executor_managerrk   s   &   r   test_shutdown_deadlock_pickle2ExecutorDeadlockTest.test_shutdown_deadlock_pickle   s     	D)A+/+;+;+=   ? ?BJ$M
 OOB#**,'@@ MO4A5)""=11
 2?& 	 21? ?s%   BD
C=	D=DDD 	c                   V P                   P                  R R7       R\        P                  ,          pV P	                  ^V P                  4       R7      ;_uu_ 4       pW n         V P                  \        4      ;_uu_ 4        \        VP                  \        V.^
,          4      4       RRR4       RRR4       XP                  R R7       R#   + '       g   i     L,; i  + '       g   i     L7; i)Tr]   arr   N)rj   rf   r   PIPE_MAX_SIZErv   rw   r|   r   listmapr   )r3   r   rj   s   &  r   test_crash_big_data(ExecutorDeadlockTest.test_crash_big_data   s     	D)W***A+/+;+;+=   ? ?BJ$M""#455X\\"2TFRK@A 6? 	t$ 65? ?s$   $C (C	)C CC  C0	c                  a V P                   P                  R R7       \        \        R4      '       g   \        P
                  ! R4      hR p\        P                  P                  P                  oV3R lp ! R R\        4      p\        P                  P                  P                  \        P                  P                  RV4      ;_uu_ 4        \        P                  P                  R	V4      ;_uu_ 4        V P                  ^V P                  4       R
7      ;_uu_ 4       pW@n         ^dp\!        V4      p\        P                  ! \        P"                  V4      p \        P$                  ! \'        V P(                  4      4       V P+                  V\-        \/        VP1                  \&        V4      4      4      4       \        P$                  ! ^ 4       \        P                  ! \        P"                  V4        RRR4       RRR4       RRR4       R#   \        P$                  ! ^ 4       \        P                  ! \        P"                  T4       i ; i  + '       g   i     Lb; i  + '       g   i     Lm; i  + '       g   i     R# ; i)Tr]   alarmz1Tested platform does not support the alarm signalc                 @    ^ RI pVP                  4        \        R4      h)r   Nz timed out while submitting jobs?)r   r`   r   )_signum_framer   s   && r   ru   [ExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.timeout  s    '')ABBr   c                 D   < \         P                  ! ^4       S! V 4       R# )   N)r   r   )r3   
thread_runs   &r   mock_run\ExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.mock_run  s    JJqMtr   c                   J   a a ] tR tRt oV 3R ltV 3R ltV 3R ltRtVtV ;t	# )^ExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeupi  c                \   < \         SV `  4        \        P                  ! ^R7      V n        R# )r   )maxsizeN)super__init__queueQueue_dummy_queuer3   	__class__s   &r   r   gExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeup.__init__  s     "$)KK$:!r   c                ^   < V P                   P                  R RR7       \        SV `  4        R # )NT)block)r   putr   wakeupr   s   &r   r   eExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeup.wakeup   s&    !!%%d$%7 r   c                   < \         SV `  4          V P                  P                  4        K    \        P
                   d     R# i ; i)TN)r   clearr   
get_nowaitr   Emptyr   s   &r   r   dExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeup.clear$  s<    ))446{{ s   . AA)r   )
r7   r8   r9   r:   r   r   r   r;   r<   __classcell__)r   r>   s   @@r   
MockWakeupr     s     ;! r   r   runz(concurrent.futures.process._ThreadWakeuprr   N)rj   rf   hasattrsignalunittestSkipTestr   process_ExecutorManagerThreadr   r   mockpatchobjectrv   rw   rangeSIGALRMr   intr~   assertEquallenr   r   )	r3   ru   r   r   rj   job_numjob_dataold_handlerr   s	   &       @r   5test_gh105829_should_not_deadlock_if_wakeup_pipe_fullJExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full  s    	D)vw''##CE E	C __;;??
	
	 	$ mm!!(()O)O).: :mm!!"L",. .##/3/?/?/A $ C CFN ( > %mmFNNGD?LLT\\!23$$Wc$x||C7R2S.TULLOMM&..+>'C.: :, LLOMM&..+>'C C. .: : :sU   )I;:*I(	$9IA!H?;I;I(	I;=III% I(	(I83I;;J	)rj   N)r7   r8   r9   r:   r   LONG_TIMEOUTr~   rn   r   r   r   r   skip_if_sanitizerr   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   r=   s   @r   rX   rX   ]   s    ""G1$%U %.>
CD CMD ND CM5 N5-D CMN NN
F
J
.O
 CM
 N
 4 CM% N%B? B?r   rX   )executor_mixinsc                      \        4        R # r   )r
   r"   r   r   setUpModuler   K  s    Nr   __main__r   )(rz   r   r   r    r   r   unittest.mockrP   r   
concurrentr   concurrent.futures.processr   r   testr   utilr	   r
   r   r   r   r   r   r#   r&   r+   r.   r   r0   r@   rE   rJ   rN   rS   rX   globalsr   r7   mainr"   r   r   <module>r     s       
       G M M




F f 6 V /F /?f ?f? f?R gi!5';'A'<'>?
 zMMO r   