
    daf-	                     ~    d 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	Z	dZ
dZdZ G d d	ej                        Zy)
ar  This test case provides support for checking forking and wait behavior.

To test different wait behavior, override the wait_impl method.

We want fork1() semantics -- only the forking thread survives in the
child after a fork().

On some systems (e.g. Solaris without posix threads) we find that all
active threads survive in the child after a fork(); this is an error.
    N)support)threading_helper   g      ?   c                   *    e Zd Zd Zd Zd Zd Zd Zy)ForkWaitc                 `    t        j                         | _        i | _        d| _        g | _        y )Nr   )r   threading_setup_threading_keyalivestopthreads)selfs    )/root/Python-3.12.4/Lib/test/fork_wait.pysetUpzForkWait.setUp   s(    .>>@
	    c                     d| _         | j                  D ]  }|j                           d }| j                  j                          t	        j
                  | j                    y )N   )r   r   joinclearr   threading_cleanupr   )r   threads     r   tearDownzForkWait.tearDown   sN    	ll 	FKKM	**D,?,?@r   c                     | j                   sIt        j                         | j                  |<   	 t	        j
                  t               | j                   sHy y # t        $ r Y w xY w)N)r   osgetpidr   timesleep
SHORTSLEEPOSError)r   ids     r   fz
ForkWait.f(   sJ    ))YY[DJJrN

:& ))  s   A 	A#"A#c                2    t        j                  ||       y )Nexitcode)r   wait_process)r   cpidr%   s      r   	wait_implzForkWait.wait_impl0   s    TH5r   c                    t        t              D ]O  }t        j                  | j                  |f      }|j                          | j                  j                  |       Q t        j                  t        j                        D ]   }t        | j                        t        k\  s  n t        | j                  j                               }| j                  |t!        t        t                           | j                  j#                         }t%        j&                  t(        d      5  t+        j,                         x}dk(  r]t/        j0                  t2               d}| j                  D ]  }| j                  |   ||   k7  s|dz  } t+        j4                  |       n| j7                  |d       d d d        y # 1 sw Y   y xY w)N)targetargsignore)categoryactionr   r   r$   )rangeNUM_THREADS	threadingThreadr"   startr   appendr   sleeping_retrySHORT_TIMEOUTlenr   sortedkeysassertEquallistcopywarningscatch_warningsDeprecationWarningr   forkr   r   	LONGSLEEP_exitr(   )	r   ir   _aprefork_livesr'   nkeys	            r   	test_waitzForkWait.test_wait3   s^   {# 	(A%%TVV1$?FLLNLL'	( ''(=(=> 	A4::+-	 4::??$%D{!345

) $$.@,46 	1	!a'

9%:: Czz#-*<<Q  ta0	1 	1 	1s   (AF;0F;;GN)__name__
__module____qualname__r   r   r"   r(   rI    r   r   r   r      s    A61r   r   )__doc__r   r   unittestr1   testr   test.supportr   r=   rA   r   r0   TestCaser   rM   r   r   <module>rS      sA   	     )  	
91x   91r   