f _@sfdZddlZddlZddlZddlZddlZddlmZddlm Z dZ dZ dZ Gdd d ej ZdS) arThis 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_helperg?c@s4eZdZddZddZddZddZd d Zd S) ForkWaitcCs t|_i|_d|_g|_dS)Nr)rZthreading_setup_threading_keyalivestopthreads)selfr '/usr/lib64/python3.10/test/fork_wait.pysetUps zForkWait.setUpcCs8d|_|jD] }|q d}|jtj|jdS)N)r r joinclearrZthreading_cleanupr)r threadr r r tearDowns    zForkWait.tearDowncCs:|js6t|j|<zttWqty4Yq0dS)N)r osgetpidrtimesleep SHORTSLEEPOSError)r idr r r f's  z ForkWait.fcCstj||ddS)Nexitcode)rZ wait_process)r cpidrr r r wait_impl/szForkWait.wait_implc Cs ttD]*}tj|j|fd}||j|qt t j }t |j tkrjtd|t krBqjqBt|j }||ttt|j }tjdvrt}nt}|dkrttd}|j D]}|j |||kr|d7}qt|n|j|dddS)N)targetargsg?)Z unixware7rrr)range NUM_THREADS threadingThreadrstartr appendr monotonicrZ SHORT_TIMEOUTlenrrsortedkeysZ assertEquallistcopysysplatformrZfork1fork LONGSLEEP_exitr) r irdeadlineaZ prefork_livesrnkeyr r r test_wait2s.          zForkWait.test_waitN)__name__ __module__ __qualname__rrrrr8r r r r rs  r)__doc__rr.rZunittestr$testrZ test.supportrr1rr#ZTestCaserr r r r s