R^s!SSKrSSKJrJrJr SSKJrJrJr SSKJ r SSK J r J r SSKJ r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr SSKJr SS KJr SS KJr \R@"S S 9 S r!Sr"Sr#Sr$"SS\%5r&"SS\RN5r("SS\RR5r*"SS\*5r+"SS\*5r,"SS\*5r-"SS\*5r."SS \RN5r/"S!S"\*5r0"S#S$\*5r1"S%S&\Rd5r2"S'S(\Rf5r4\Rj"\RlSLS)5"S*S+\Rf55r7"S,S-\Rp5r8"S.S/\Rf5r9"S0S1\Rt5r:"S2S3\Rv5r;"S4S5\Rx5r<"S6S7\Rz5r="S8S9\RR5r>"S:S;\RR5r?"S<S=\RR5r@\AS>:Xa\R"5 gg!\a SrGNf=f)?N)threading_helperrequires_subprocessrequires_gil_enabled)verbose cpython_only os_helper) import_module)assert_python_okassert_python_failure)force_not_colorized)mock) lock_tests)support) interpretersT)module)netbsd5zhp-ux11c[R(d[R"S5"U5$[R [ ;a[R"S5"U5$[R(a[R"S5"U5$[R"SS9(a[R"S5"U5$U$)Nzrequires working os.fork()z*due to known OS bug related to thread+forkz?libasan has a pthread_create() dead lock related to thread+forkTthreadz'TSAN doesn't support threads after fork) rhas_fork_supportunittestskipsysplatformplatforms_to_skipHAVE_ASAN_FORK_BUGcheck_sanitizer)tests :/opt/alt/python313/lib64/python3.13/test/test_threading.pyskip_unless_reliable_forkr ,s  # #}}9:4@@ ||((}}IJ4PP!!}}^_`deed+}}FGMM KcH[R"[SLS5"U5$)Nzsubinterpreters required)rskipIfr)meths rrequires_subinterpretersr%8s% ??<4/5 77; ==r!cUR[[S[R5 [R[lg)N excepthook) addCleanupsetattr threadingr'__excepthook__)testcases rrestore_default_excepthookr->s* L):N:NO$33Ir!c,\rSrSrSrSrSrSrSrg)CounterDcSUlgNrvalueselfs r__init__Counter.__init__Es  r!c.U=RS- slgNr3r5s rinc Counter.incG a r!c.U=RS-slgr:r3r5s rdec Counter.decIr>r!cUR$Nr3r5s rget Counter.getKs zzr!r3N) __name__ __module__ __qualname____firstlineno__r7r<r@rD__static_attributes__r!rr/r/Dsr!r/c \rSrSrSrSrSrg) TestThreadNcn[RRXS9 X lX0lX@lXPlg)Nname)r*Threadr7r,semamutexnrunning)r6rQr,rSrTrUs rr7TestThread.__init__Os-!!$!2    r!c[R"5S- n[(a[SURUS-4-5 UR UR  UR R5 [(a$[UR R5S5 URRUR R5S5 SSS5 [R"U5 [(a[SURS5 UR  UR R5 URRUR R5S5 [(a2[S URUR R54-5 SSS5 SSS5 g!,(df  N=f!,(df  N(=f!,(df  g=f) Ng@ztask %s will run for %.1f usecg.Aztasks are runningtaskdonerz$%s is finished. %d tasks are running)randomrprintrQrSrTrUr<rDr,assertLessEqualtimesleepr@assertGreaterEqual)r6delays rrunTestThread.runVsE ') 7 299eck*+ ,YY !!#7$--++-/BC --dmm.?.?.A1E  JJu wfdii0 !!# 001B1B1DaH7@99dmm&7&7&9:;< YYs? G#A>GA G#$B G0G# G G# G G## G1)rTrUrSr,N)rFrGrHrIr7rbrJrKr!rrMrMNs !.func}Dr!myname1rP{123myname2)targetrQ_counter) return_valuezThread-2rXzThread-3r}zThread-5 (func))r*rR assertEqualrQr patchobject)r6rvrs r test_nameThreadTests.test_name{sd!!y1 i0!!s+ e,!!I> i0 ZZ  y*1  E%%2.F   V[[* 5FZZ  y*1  E%%'F   V[[* 5FZZ  y*1  E%%T2F   V[[*; <F EF EF EF Es$81F+2F<11G + F9< G  GcR^S/nSnS/nSnS/4nS/nUU4Sj4UU4Sj4UU4Sj4UU4Sj4UU4S j4UU4S j44nUHQupTRXS 9 [R"XS 9n U R5 U R 5 SSS5 MS g!,(df  Me=f) Nr;r;strrc(>TRUS5$r:rargr6s r0ThreadTests.test_args_argument..s4#3#3C#;r!c(>TRUS5$r:rrs rrrsD$4$4S!$TRUS5$Nrrrs rrrs4#3#3C#?r!c(>TRUS5$rrrs rrrsD$4$4S%$@r!c*>TRUS/5$r:rrs rrrs(8(8qc(Br!c(>TRUS5$)Nrrrs rrrs(8(8d(Cr!r}args)subTestr*rRstartjoin) r6num_list num_tuplestr_list str_tuple list_in_tuple tuple_in_list test_casesrr}ts ` rtest_args_argumentThreadTests.test_args_arguments3 7   ; < < = ? @ @ A B C C D  'LDV7$$F> 87'77s 5B B& c  [R"5 UR[[RS5 UR[[RSS9 UR[[RSSSSS9 g)Nr;)ar)rb)r*Lock assertRaises TypeErrorr5s rtest_lock_no_argsThreadTests.test_lock_no_argssZ )Y^^Q7 )Y^^q9 )Y^^QQ!Dr!cUR[5 "SS[R5nSSS5 g!,(df  g=f)Nc\rSrSrSrg)1ThreadTests.test_lock_no_subclass..MyLockrKNrFrGrHrIrJrKr!rMyLockrs$r!r)rrr*r)r6rs rtest_lock_no_subclass!ThreadTests.test_lock_no_subclasss*  y ) . .* ) )s 9 AcfSSKnUR[RS-UR5 gr2)typesassertIsInstancer*r UnionType)r6rs rtest_lock_or_noneThreadTests.test_lock_or_nones" innt3U__Er!cSn[R"SS9n[R"5n[5n/n[ U5Hjn[ SU-XX45nUR U5 URUR5 UR[U5S5 UR5 Ml [[S5(aY[SU55[R"51-nURSU5 UR![#U5US-5 [$(a ['S 5 UHnUR)5 UR+UR-55 UR/URS 5 UR1UR5 UR[U5S 5 M [$(a ['S 5 UR!UR35S 5 g) N rXr3z z^$ get_native_idc38# UHoRv M g7frC) native_id).0rs r /ThreadTests.test_various_ops..s:'Q[['sr;z!waiting for all tasks to completerz#^$zall tasks done)r*BoundedSemaphoreRLockr/rangerMappend assertIsNoneident assertRegexreprrhasattrsetr assertNotInrlenrr\r assertFalseis_aliveassertNotEqualassertIsNotNonerD) r6NUMTASKSrSrT numrunningthreadsir native_idss rtest_various_opsThreadTests.test_various_opss~))2!Y xA=?DJA NN1    agg &   T!W&F G GGI ! 9o . .:'::i>U>U>W=XXJ   T: .   S_hl ; 7 5 6A FFH   QZZ\ *    +   )   T!W&L M  7 " # )1-r!cv^^UR[R"5R5 UU4Sjn[R"5m/m[ R "5 [R"US5nTR5 URTSU5 SSS5 g!,(df  g=f)Nc>TR[R"5R5 TR 5 grC)rr*current_threadrr)rZrsrf9ThreadTests.test_ident_of_no_threading_threads..fs' LL11399 : HHJr!rKr) rr*rrEventrwait_threads_exit_threadstart_new_threadwaitr)r6rtidrZrs @@r"test_ident_of_no_threading_threads.ThreadTests.test_ident_of_no_threading_threadss Y557==>    / / 1**1b1C IIK   U1Xs +2 1 1s $=B** B8c[(a [S5 [R"S5 UR5 [R"S5 g![R a [ R"S5ef=f)Nz!with 256 KiB thread stack size...i4platform does not support changing thread stack sizer rr\r* stack_sizererrorrSkipTestrr5s rtest_various_ops_small_stack(ThreadTests.test_various_ops_small_stackso 7 5 6 H   ( Q }} H##FH H H A+Bc[(a [S5 [R"S5 UR5 [R"S5 g![R a [ R"S5ef=f)Nzwith 1 MiB thread stack size...irrrr5s rtest_various_ops_large_stack(ThreadTests.test_various_ops_large_stackso 7 3 4 H   * Q }} H##FH H Hrc^^^SmSmUUU4Sjn[R"5nUR5 [R"5 [ R "X45nUR5 SSS5 TbTeTRWTR5 TR[5 TR5 SSS5 TRR5 TR[5 TR5 SSS5 Sn[R "5U-n[R "5U:a^[R"R%TR5TLag[R&"S5 [R "5U:aM^TR)S5 g!,(df  GNI=f!,(df  GN =f!,(df  N=f)Nc>[R"5mTRnTRU[R5 TR T[R 5 TR[RRU5T5 TRTR5S5 TRS[T55 UR5 g![a nUmSnAN"SnAff=f!UR5 f=f)Nz-Expected _DummyThread to be considered alive. _DummyThread)r*rrassertIn_activerrassertIsrD assertTruerr BaseExceptionrelease)rTre dummy_threadrr6s rr*ThreadTests.test_foreign_thread..fs )779 "(( c9#4#45%%lI4J4JK i//33C8,G ))+C nd<.@A !   s*C C C5)C0+C80C55C88D r皙?z[It was expected that the created threading._DummyThread was removed from threading._active.)r*racquirerrrrrrr RuntimeErrorr_startedclearrr^ monotonicrrDr_fail)r6rrTrtimeout timeout_atrrs` @@rtest_foreign_threadThreadTests.test_foreign_thread sW  ,    / / 1**1h7C MMO2  K l001   | ,    -##%   | ,  ! ! #-^^%/ nn+  $$\%7%78 L JJrNnn+ IIs t-2 1- ,- ,s$ (F40G8G4 G G G&cf^ ^ ^ [S5nURRnURUR4Ul"SS[ 5m UR T 5n[R"5nURU[5 URUS5 U"XC5nM!T a Of=fURWS5 O![a Of=f[R"5m [R"5m "U U U 4SjS[R 5nU"5nSUlUR%5 [&(a [)S 5 [&(a [)S 5 U"S U5nURUS5 [&(a [)S 5 T R+5nUR-U5 [&(a [)S 5 UR/UR05 [&(a [)S5 U"UR2U5nURUS5 [&(a [)S5 T R+[4R6S9 UR-UR05 [&(a [)S5 UR0(aUR95 gg)Nctypesc\rSrSrSrg).AsyncExciHrKNrrKr!rAsyncExcrHs r!rrTr;c&>\rSrSrUUU4SjrSrg):ThreadTests.test_PyThreadState_SetAsyncExc..Workerikc>[R"5UlSUlTR 5 [ R "S5 M(!Ta SUlTR 5 gf=f)NFTr)r* get_identidfinishedrr^r_)r6rworker_saw_exceptionworker_starteds rrb>ThreadTests.test_PyThreadState_SetAsyncExc..Worker.runlsb#--/ % /&**, 3 /$(DM(,,./s)A A-,A-)rrNrFrGrHrIrbrJ)rrrsrWorkerrks  / /r!rz started worker threadz trying nonsensical thread idz, waiting for worker thread to get startedz" verifying worker hasn't exitedz2 attempting to raise asynch exception in workerz5 waiting for worker to say it caught the exceptionr z all OK -- joining worker)r pythonapiPyThreadState_SetAsyncExcc_ulong py_objectargtypes Exceptionr*rrint assertGreaterrrUnboundLocalErrorrrRdaemonrrr\rrrrrr SHORT_TIMEOUTr) r6r set_async_exc exceptionrresultrrretrrrs @@@rtest_PyThreadState_SetAsyncExc*ThreadTests.test_PyThreadState_SetAsyncExcBs-x(((BB "(..&2B2B!C  y $$X. !!# c3' 3" -"32F        VQ '    #*(0 / /Y%% / H  7 - . 7 4 5r9- # 7 @ A!!#  7 6 7 $ 7 F GqttY/ # 7 I J!!'*?*?!@  # 7 0 1 :: FFH s$ B,,B54B59C CCc<Sn[RnU[l[R"SS9nUR[RUR 5 UR U[R;S5 U[lg!U[lf=f)Nc,[R"5erC)r* ThreadErrorrkwargss rfail_new_thread7ThreadTests.test_limbo_cleanup..fail_new_threads'') )r!cgrCrKrKr!rr0ThreadTests.test_limbo_cleanup..r!rz:Failed to cleanup _limbo map on failure of Thread.start().)r*_start_joinable_threadrRrr2rr_limbo)r6r5r:rs rtest_limbo_cleanupThreadTests.test_limbo_cleanups *!*!A!A+: ( F  5A   i33QWW =   Y%%%L N0FI ,/EI ,s A"B Bc[R"SS9(aURS5 [S5 [ SS5upnUR US5 g)NTrTSAN would report thread leakr-caNif 1: import ctypes, sys, time, _thread # This lock is used as a simple event variable. ready = _thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) _thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) *)rrskipTestr r rr6rcouterrs rtest_finalize_running_thread(ThreadTests.test_finalize_running_threadsP  " "$ / MM9 :h,T4 2 R r!cp[R"SS9(aURS5 [SS5 g)NTrr?r@aPif 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print('program blocked; aborting') os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) )rrrBr r5s rtest_finalize_with_trace$ThreadTests.test_finalize_with_traces0  " "$ / MM9 :  r!c[SS5upnURUR5S5 URUS5 g)Nr@aif 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print("Woke up, sleep function is:", sleep) threading.Thread(target=child).start() raise SystemExit s5Woke up, sleep function is: r!r rstriprCs rtest_join_nondaemon_on_shutdown+ThreadTests.test_join_nondaemon_on_shutdownsE( /    D F c"r!c[Rn[R"5n[ SS5Hnn[ R "US-5 [R"SS9nUR5 UR5 U"5nURXESX54-5 Mp [R "U5 g![R "U5 f=f)Nr;dg-C6*?cgrCrKrKr!rr7ThreadTests.test_enumerate_after_join..sDr!rz� triggered after %d trials: %s) r* enumeratergetswitchintervalrrsetswitchintervalrRrrr)r6enum old_intervalrrls rtest_enumerate_after_join%ThreadTests.test_enumerate_after_joins"",,.  01c]))!f*5$$L9 F  <vEG #  ! !, /C ! !, /s A>B<<CiFsizememusedry_runc ^/mSnU4Sjn[SS5Hn[R"US9/n[U5H+nUR[R"UUS4S95 M- UHnUR 5 M [ R "S5 UHnUR5 M T(dMTSe g) Nc0[R"S5 g)Ng{Gzt?r^r_rKr!rworker;ThreadTests.test_join_from_multiple_threads..workers JJu r!cx>UR5 g![anTRU5 SnAgSnAff=frC)rr$r)rrerrorss rjoiner;ThreadTests.test_join_from_multiple_threads..joiners0 !  ! a   !s 949rr]rrr{Gz?)rr*rRrrr^r_r) r6r_reriNrrrrhs @rtest_join_from_multiple_threads+ThreadTests.test_join_from_multiple_threadss  ! q"A ''v67G1Xy//v6=aj] DE  JJt vQir!c^[R"5mTR5 U4Sjn[R"US9nUR 5 UR SS9 TR5 UR 5 g)Nc&>TR5 grC)r)locksrre2ThreadTests.test_join_with_timeout..worker0s LLNr!rrkr)r allocate_lockrr*rRrrr)r6rerrqs @rtest_join_with_timeout"ThreadTests.test_join_with_timeout,sZ$$&  !!0  D !  r!c"SS[5n[U5 U"SS9n[R"U5nURR 5 AUR U"5S[R"U"55-S9 U"SS9n[R"U5nURR 5 AUR U"5S[R"U"55-S9 g)Nc \rSrSrSrSrSrg)DThreadTests.test_no_refcycle_through_target..RunSelfFunctioni<cXl[R"URU4SU0S9UlURR 5 g)N yet_another)r}rr4) should_raiser*rR_runrr)r6r{s rr7MThreadTests.test_no_refcycle_through_target..RunSelfFunction.__init__=sB%1!'..dii59G7DT6JL  !!#r!c2UR(a[egrC)r{ SystemExit)r6 other_refrzs rr|IThreadTests.test_no_refcycle_through_target..RunSelfFunction._runFs$$$$%r!)r{rN)rFrGrHrIr7r|rJrKr!rRunSelfFunctionrx<s  $ %r!rF)r{z%d references still around)msgT) rr-weakrefrefrrrr getrefcount)r6r cyclic_objectweak_cyclic_objectraising_cyclic_objectweak_raising_cyclic_objects rtest_no_refcycle_through_target+ThreadTests.test_no_refcycle_through_target;s %f % #4('U; $[[7!!#  ,.:!oo.@.BCD  F!0T B%,[[1F%G"$$))+ ! 46:!oo.H.JKL  Nr!c[R"5nUR[S5 UR 5 SSS5 UR[S5 UR S5 SSS5 UR[S5 UR 5 SSS5 UR[S5 URS5 SSS5 [R"5nUR[S5 UR5 SSS5 [R"5nUR5 UR[S5 UR5 SSS5 UR[S 5 [R"5 SSS5 UR[S 5 [R"5 SSS5 g!,(df  GN=f!,(df  GN=f!,(df  GNd=f!,(df  GNF=f!,(df  GN=f!,(df  N=f!,(df  N=f!,(df  g=f) Nzget the daemon attributezset the daemon attributeTzget the name attributezset the name attributerQz use is_set()zuse notify_all()zuse active_count()zuse current_thread())r*rRassertWarnsRegexDeprecationWarningisDaemon setDaemongetNamesetNamerisSet Conditionr notifyAll activeCount currentThread)r6rrconds rtest_old_threading_api"ThreadTests.test_old_threading_api\s      " "#5#>@ JJL@ " "#5#>@ KK @ " "#5#<> IIK> " "#5#<> IIf > OO   " "#5~ F GGIG""$   " "#57I J NN K " "#57K L  ! ! #M  " "#57M N  # # %O N1@@@@>>>> G F K JM L N Ns_GG' G9:H ?HH/I6I G$' G69 H H H,/ H= I Ic[R"5nURS[U55 SUlUR S[U55 gNr(T)r*rRrrr(rr6rs rtest_repr_daemonThreadTests.test_repr_daemon{s=     47+ hQ(r!c [R"5nURUR5 [R"SS9nURUR5 [R"SS9nUR UR5 g)NF)r(T)r*rRrr(rrs rtest_daemon_paramThreadTests.test_daemon_paramsd     "   E * "   D ) !r!cnSn[SU5up#nURUS5 URUS5 g)Naif 1: import _thread, threading, os, time, warnings def background_thread(evt): # Creates and registers the _DummyThread instance threading.current_thread() evt.set() time.sleep(10) evt = threading.Event() _thread.start_new_thread(background_thread, (evt,)) evt.wait() assert threading.active_count() == 2, threading.active_count() with warnings.catch_warnings(record=True) as ws: warnings.filterwarnings( "always", category=DeprecationWarning) if os.fork() == 0: assert threading.active_count() == 1, threading.active_count() os._exit(0) else: assert ws[0].category == DeprecationWarning, ws[0] assert 'fork' in str(ws[0].message), ws[0] os.wait() r@r!r rr6code_rErFs rtest_dummy_thread_after_fork(ThreadTests.test_dummy_thread_after_forks; 0'tT2  c" c"r!c^[R"5nUR[RU5 [R RS5 [ S5Hn[R"SS9nUR5 [R"[SS9 [R"5=nS:Xa.[R"UR!5(aSOS 5 O%UR#5 [ R$"US S 9 SSS5 M g!,(df  M=f) Ngư>r]cgrCrKrKr!rr6ThreadTests.test_is_alive_after_fork..r9r!rignorecategoryactionr rexitcode)rrVr(rWrrrr*rRrwarningscatch_warningsrosfork_exitrr wait_process)r6rYrrpids rtest_is_alive_after_fork$ThreadTests.test_is_alive_after_forks,,.  --|< &&t,rA  5A GGI((2D08:779$C*HH1::<TR[R"5R[R"5R5 grC)rr* main_threadrrr5srr'ThreadTests.test_main_thread..fs5    5 5 7 = = ) 8 8 : @ @ Br!r) r*rrrQrrrrRrr)r6mainrths` rtest_main_threadThreadTests.test_main_threads$$& L1 Y%=%=%?%E%EF Y%8%8%:; B  Q '    r!waitpidztest needs os.waitpid()cSn[SU5up#nUR5RSS5nURUS5 URUS5 g)Na!if 1: import os, threading from test import support ident = threading.get_ident() pid = os.fork() if pid == 0: print("current ident", threading.get_ident() == ident) main = threading.main_thread() print("main", main.name) print("main ident", main.ident == ident) print("current is main", threading.current_thread() is main) else: support.wait_process(pid, exitcode=0) r@ rr!zHcurrent ident True main MainThread main ident True current is main True r decodereplacerr6rrrErFdatas rtest_main_thread_after_fork'ThreadTests.test_main_thread_after_forksX 'tT2 zz|##D"- c" 2 3r!cSn[SU5up#nUR5RSS5nURURS5S5 URUS5 g)Naif 1: import os, threading, sys, warnings from test import support def func(): ident = threading.get_ident() with warnings.catch_warnings(record=True) as ws: warnings.filterwarnings( "always", category=DeprecationWarning) pid = os.fork() if pid == 0: print("current ident", threading.get_ident() == ident) main = threading.main_thread() print("main", main.name, type(main).__name__) print("main ident", main.ident == ident) print("current is main", threading.current_thread() is main) # stdout is fully buffered because not a tty, # we have to flush before exit. sys.stdout.flush() else: assert ws[0].category == DeprecationWarning, ws[0] assert 'fork' in str(ws[0].message), ws[0] support.wait_process(pid, exitcode=0) th = threading.Thread(target=func) th.start() th.join() r@rrutf-8zTcurrent ident True main Thread-1 (func) Thread main ident True current is main True rrs r/test_main_thread_after_fork_from_nonmain_thread;ThreadTests.test_main_thread_after_fork_from_nonmain_threadsa 8'tT2 zz|##D"- G,b1 2 r!cSU-n[SSSU5up4nUR5RSS5nURUR5S5 URUU(aSOSSU<S 3-S -5 g) NaCif 1: import os, threading, sys, traceback, _thread from test import support def func(lock): ident = threading.get_ident() if %s: # call current_thread() before fork to allocate DummyThread current = threading.current_thread() print("current", current.name, type(current).__name__) print("ident in _active", ident in threading._active) # flush before fork, so child won't flush it again sys.stdout.flush() pid = os.fork() if pid == 0: print("current ident", threading.get_ident() == ident) main = threading.main_thread() print("main", main.name, type(main).__name__) print("main ident", main.ident == ident) print("current is main", threading.current_thread() is main) print("_dangling", [t.name for t in list(threading._dangling)]) # stdout is fully buffered because not a tty, # we have to flush before exit. sys.stdout.flush() try: threading._shutdown() os._exit(0) except: traceback.print_exc() sys.stderr.flush() os._exit(1) else: try: support.wait_process(pid, exitcode=0) except Exception: # avoid 'could not acquire lock for # <_io.BufferedWriter name=''> at interpreter shutdown,' traceback.print_exc() sys.stderr.flush() finally: lock.release() join_lock = _thread.allocate_lock() join_lock.acquire() th = _thread.start_new_thread(func, (join_lock,)) join_lock.acquire() z-Wzignore::DeprecationWarningr@rrzcurrent Dummy-1 _DummyThread zident in _active  zmcurrent ident True main MainThread _MainThread main ident True current is main True _dangling ['MainThread'] r)r6 create_dummyrrrErFrs r/test_main_thread_after_fork_from_foreign_thread;ThreadTests.test_main_thread_after_fork_from_foreign_threads. \].b't-I4QUV zz|##D"- r* >J:PR,\,TR5 TR5 grC)rr)finishstartedsrr(ThreadTests.test_repr_stopped..fs OO  NN r!rrstoppedirk) rrsrr*rRrrrrrr^r_r)r6rr LOOKING_FORrrrs @@rtest_repr_stoppedThreadTests.test_repr_stoppeds'')&&(    A &   ia)  sAd1g% JJt  k47+ r!cR[SS5GH n[R"U5n[U5Vs/sH!n[R"URS9PM# nnUHnUR 5 M UHnUR 5 M [U5Vs/sH!n[R"URS9PM# nnUHnUR 5 M UHnUR 5 M UR[UR5 GM gs snfs snf)Nr;rr) rr*rrRrrrrr ValueError)r6limitbsrrrs rtest_BoundedSemaphore_limit'ThreadTests.test_BoundedSemaphore_limits1b\E++E2B %e . ,1!''rzz: , . !&e . ,1!''rzz: , .    j"** 5". .s (D(D$c^^^[S5nU4SjmSmUU4SjmSTl[R"5n[R"T5 [ R"T5 UR T5 [S5H nT"5 M [R"U5 [ R"U5 g![R"U5 [ R"U5 f=f)N _testcapic>T$rCrKframeeventr noop_traces rr9ThreadTests.test_frame_tstate_tracing..noop_trace  r!c3# Sv M7f)N generatorrKrKr!rr8ThreadTests.test_frame_tstate_tracing..generators!!s c`>TRc T"5Tl[TR5$rC)gennext)callbackrsrr7ThreadTests.test_frame_tstate_tracing..callbacks%||#({  % %r!rX)r rrgettracesettracer*call_in_temporary_c_threadr)r6r old_tracerrrrs @@@rtest_frame_tstate_tracing%ThreadTests.test_frame_tstate_tracings!+.   " & LLN  Z  *   z *  0 0 :a ! LL #   y ) LL #   y )s AB??.C-c^U4Sjm[R"5n[R"T5 [R"5nURTU5 [R"U5 g![R"U5 f=f)Nc>T$rCrKrs rr-ThreadTests.test_gettrace..noop_tracerr!)r*rrr)r6r trace_funcrs @r test_gettraceThreadTests.test_gettracesf &&(  *   z *"++-J   Z 3   y )I  y )s =A22B c*^^^Sn[R"5n[R"5m[R"5m/mUUU4Sjn[R"US9nUR 5 TR 5 [R "U5 TR5 UR5 URTSU/5 UR[R"5U5 UR[R"5U5 [R "U5 UR[R"5U5 UR[R"5U5 g![R "U5 f=f)NcgrCrKrs rfn1ThreadTests.test_gettrace_all_threads..fntr!c>TR[R"55 TR5 TR 5 TR[R"55 grC)rrrrr) first_check second_check trace_funcssrchecker6ThreadTests.test_gettrace_all_threads..checkersA   s||~ . OO        s||~ .r!r) r*rrrRrrsettrace_all_threadsrrrr)r6rrrrrrrs @@@rtest_gettrace_all_threads%ThreadTests.test_gettrace_all_threadss&&( oo'  (   / 6  0A GGI      * *2 .     FFH   [4* 5   Y//12 6   S\\^R 0  * *9 5 ++-y9 3  * *9 5 CE::FcSn[R"5n[R"U5 URU[R"55 [R"U5 g![R"U5 f=f)NcgrCrKrs rr'ThreadTests.test_getprofile..fnrr!)r* getprofile setprofiler)r6r old_profiles rtest_getprofileThreadTests.test_getprofiles\**,  .   $   R!5!5!7 8   -I  -s ;A,,Bc*^^^Sn[R"5n[R"5m[R"5m/mUUU4Sjn[R"US9nUR 5 TR 5 [R "U5 TR5 UR5 URTSU/5 UR[R"5U5 UR[R"5U5 [R "U5 UR[R"5U5 UR[R"5U5 g![R "U5 f=f)NcgrCrKrs rr3ThreadTests.test_getprofile_all_threads..fnrr!c>TR[R"55 TR5 TR 5 TR[R"55 grC)rrr$rr)r profile_funcsrsrr8ThreadTests.test_getprofile_all_threads..checker#sC  !1 2 OO       !1 2r!r) r*r$rrRrrsetprofile_all_threadsrrrr)r6rr&rrrr-rs @@@rtest_getprofile_all_threads'ThreadTests.test_getprofile_all_threadss**, oo'  (   3 :  0A GGI      , ,R 0     FFH   ]T2J 7   Y113R 8   S^^-r 2  , ,[ 9 --/= );7  , ,[ 9r cb[SS5upnURUR5S5 g)Nr@a(if 1: import threading class Atexit: def __del__(self): print("thread_dict.atexit = %r" % thread_dict.atexit) thread_dict = threading.local() thread_dict.atexit = "value" atexit = Atexit() sthread_dict.atexit = 'value')r rrstriprCs rtest_locals_at_exitThreadTests.test_locals_at_exit9s2( /   'FGr!c"SS[5nU"5n[R"US9nUR5 UR 5 UR UR 5 g)Nc&\rSrSrSrSrSrSrg)6ThreadTests.test_boolean_target..BooleanTargetiOcSUlgNFranr5s rr7?ThreadTests.test_boolean_target..BooleanTarget.__init__Ps  r!cgr:rKr5s r__bool__?ThreadTests.test_boolean_target..BooleanTarget.__bool__Rsr!cSUlg)NTr;r5s r__call__?ThreadTests.test_boolean_target..BooleanTarget.__call__Ts r!r;N)rFrGrHrIr7r?rBrJrKr!r BooleanTargetr8Os !  r!rDr)rr*rRrrrr<)r6rDr}rs rtest_boolean_targetThreadTests.test_boolean_targetJsI  F !!0    #r!cSn[R"5 [R"US9R 5 SSS5 g!,(df  g=f)NcgrCrKrKr!rnoop0ThreadTests.test_leak_without_join..noop`rxr!r)rrr*rRr)r6rIs rtest_leak_without_join"ThreadTests.test_leak_without_join]s6   / / 1   D ) / / 12 1 1s #A Ac[R"S5n[SU5up#nURUS5 URUS5 g)Na import _thread import sys event = _thread.allocate_lock() event.acquire() def import_threading(): import threading event.release() if 'threading' in sys.modules: raise Exception('threading is already imported') _thread.start_new_thread(import_threading, ()) # wait until the threading module is imported event.acquire() event.release() if 'threading' not in sys.modules: raise Exception('threading is not imported') # don't wait until the thread completes r@r!)textwrapdedentr rrs rtest_import_from_another_thread+ThreadTests.test_import_from_another_threadesI  2(d3  c" c"r!cSn[SU5up#nURUR5S5 URSU5 g)Na6if 1: import _thread def f(): print("shouldn't be printed") class AtFinalization: def __del__(self): print("OK") _thread.start_new_thread(f, ()) at_finalization = AtFinalization() r@OKs/can't create new thread at interpreter shutdown)r rrNrrs r%test_start_new_thread_at_finalization1ThreadTests.test_start_new_thread_at_finalizations@  'tT2  e, H#Nr!c SSKJnJn Sn[ SSU5upVnUR 5nSU;aUR S5 URUS5 URUS 5 g![anUR U5 SnAN~SnAff=f) Nr) setrlimit RLIMIT_NPROCaif 1: import resource import _thread def f(): print("shouldn't be printed") limits = resource.getrlimit(resource.RLIMIT_NPROC) [_, hard] = limits resource.setrlimit(resource.RLIMIT_NPROC, (0, hard)) try: handle = _thread.start_joinable_thread(f) except RuntimeError: print('ok') else: print('!skip!') handle.join() z-ur@s!skip!z.RLIMIT_NPROC had no effect; probably superusersokr!)resourcerWrX ImportErrorrBr rNr)r6rWrXrFrrrEs rtest_start_new_thread_failed(ThreadTests.test_start_new_thread_faileds   8 &'tT48 iik   MMJ K e$ c"5  MM#   sA(( B 2BB rz$test needs threading.get_native_id()cSn[SU5up#nURUS5 URUS5 UR5R5nUR[ U5S5 UR USUS5 g)NaBif True: import threading import os from test import support parent_thread_native_id = threading.current_thread().native_id print(parent_thread_native_id, flush=True) assert parent_thread_native_id == threading.get_native_id() childpid = os.fork() if childpid == 0: print(threading.current_thread().native_id, flush=True) assert threading.current_thread().native_id == threading.get_native_id() else: try: assert parent_thread_native_id == threading.current_thread().native_id assert parent_thread_native_id == threading.get_native_id() finally: support.wait_process(childpid, exitcode=0) r@rr!rr;)r rrNrrr)r6scriptrDrErFrs rtest_native_id_after_fork%ThreadTests.test_native_id_after_forks{&(f5  Q c"YY[++-  Z!, JqM:a=9r!rKN)F)) "##>;;,  Y/1JK3L32 Y/1JK%L%N Y/1JK<7L<7|P5:!#F66$&*&*P *4:.8:H"$&2#BO"!#H O<>de:f:r!rrc\rSrSrSrSr\S5r\S5r\ R"\ R\ ;S5\R"SSS S 9S 55rS r\S 5r\S5rSrg)ThreadJoinOnShutdownicSU-n[SU5up#nUR5RSS5nURUS5 g)Naif 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print('end of thread') # stdout is fully buffered because not a tty, we have to flush # before exit. sys.stdout.flush() r@rrzend of main end of thread r)r6r^rDrErFrs r _run_and_join"ThreadJoinOnShutdown._run_and_joinsN  (f5 zz|##D"- =>r!c*SnURU5 g)Nzif 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print('end of main') rgr6r^s rtest_1_join_on_shutdown,ThreadJoinOnShutdown.test_1_join_on_shutdowns 6"r!c*SnURU5 g)Naif 1: from test import support childpid = os.fork() if childpid != 0: # parent process support.wait_process(childpid, exitcode=0) sys.exit(0) # child process t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print('end of main') rjrks rtest_2_join_in_forked_process2ThreadJoinOnShutdown.test_2_join_in_forked_processs 6"r!c*SnURU5 g)Naif 1: from test import support main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: # parent process support.wait_process(childpid, exitcode=0) sys.exit(0) # child process t = threading.Thread(target=joiningfunc, args=(main_thread,)) print('end of main') t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() rjrks r!test_3_join_in_forked_from_thread6ThreadJoinOnShutdown.test_3_join_in_forked_from_thread s * 6"r!zdue to known OS bug(i`Fr^c[R"SS9(aURS5 Sn[SU5up4nUR U5 g)NTrr?aif True: import os import random import sys import time import threading thread_has_run = set() def random_io(): '''Loop for a while sleeping random tiny amounts and doing some I/O.''' import test.test_threading as mod while True: with open(mod.__file__, 'rb') as in_f: stuff = in_f.read(200) with open(os.devnull, 'wb') as null_f: null_f.write(stuff) time.sleep(random.random() / 1995) thread_has_run.add(threading.current_thread()) def main(): count = 0 for _ in range(40): new_thread = threading.Thread(target=random_io) new_thread.daemon = True new_thread.start() count += 1 while len(thread_has_run) < count: time.sleep(0.001) # Trigger process shutdown sys.exit(0) main() r@)rrrBr r)r6r_r^rDrErFs rtest_4_daemon_threads*ThreadJoinOnShutdown.test_4_daemon_threads'sI  " "$ / MM9 :!D(f5  r!cSn[SU5up#nURUS5 URUR5S5 URUS5 g)Naif True: import threading import time def thread2(): time.sleep(0.05) print("OK") def thread1(): time.sleep(0.05) t2 = threading.Thread(target=thread2) t2.start() t = threading.Thread(target=thread1) t.start() # do not join() -- the interpreter waits for non-daemon threads to # finish. r@r!rSrrMr6r^rDrErFs rtest_thread_from_thread,ThreadJoinOnShutdown.test_thread_from_threadWsQ$(f5  c" e, Qr!c4Sn[R"[SS9 /n[S5H8n[R "US9nUR U5 UR5 M: UHnUR5 M SSS5 g!,(df  g=f)Nc[R"5nUS:a[R"USS9 g[R"S5 g)Nr2r)rrrrr)rs rdo_fork_and_waitIThreadJoinOnShutdown.test_reinit_tls_after_fork..do_fork_and_waitts/'')CQw$$S26 r!rrr) rrrrr*rRrrr)r6rrrrs rtest_reinit_tls_after_fork/ThreadJoinOnShutdown.test_reinit_tls_after_forkos}   $ $.@,46G2Y$$,<=q!  666s A#B  Bcn/n[S5H9n[R"SS9nURU5 UR 5 M; [ R "[SS9 [R"5nUS:XaP[[R"55S:Xa[R"S5 O,[R"S 5 O[R"USS 9 SSS5 UHnUR!5 M g!,(df  N(=f!UHnUR!5 M f=f) Nrc.[R"S5$)Ng333333?rdrKr!rrKThreadJoinOnShutdown.test_clear_threads_states_after_fork..s Cr!rrrrr;34r)rr*rRrrrrrrrrr_current_framesrrrr)r6rrrrs r$test_clear_threads_states_after_fork9ThreadJoinOnShutdown.test_clear_threads_states_after_forks rA  (@AA NN1  GGI  ((2D08:ggi!83..01Q6  ((r::::s% D%BD&D DDD4rKN)rFrGrHrIrgrlr rorrrr#rrrrrbrvrzrrrJrKr!rreres?" ###&##6__S\\%668MN R%@,AO,\ 02r!rec|\rSrSrSrSrSr\S5r\ S5r SSSSS .S jjr \ S 5r \ S 5r S rg)SubinterpThreadingTestsic[R"5upUR[RU5 UR[RU5 [ [S5(a[R "US5 X4$)N set_blockingF)rpiper(closerr)r6rws rrSubinterpThreadingTests.pipesUwwy !$ !$ 2~ & & OOAu %v r!c UR5up[R"SU4-5n[RR U5nUR US5 UR [R"US5S5 g)Na import os import random import threading import time def random_sleep(): seconds = random.random() * 0.010 time.sleep(seconds) def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. random_sleep() os.write(%d, b"x") threading.Thread(target=f).start() random_sleep() rr;x rrNrOrrrun_in_subinterprrreadr6rrrr-s rtest_threads_join)SubinterpThreadingTests.test_threads_joinspyy{ $d% &ll++D1 a  A-r!c UR5up[R"SU4-5n[RR U5nUR US5 UR [R"US5S5 g)Na import os import random import threading import time def random_sleep(): seconds = random.random() * 0.010 time.sleep(seconds) class Sleeper: def __del__(self): random_sleep() tls = threading.local() def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. random_sleep() tls.x = Sleeper() os.write(%d, b"x") threading.Thread(target=f).start() random_sleep() rr;rrrs rtest_threads_join_2+SubinterpThreadingTests.test_threads_join_2sp yy{ 2d3 4ll++D1 a  A-r!cUR5upSnSnSn[R"5nURSUSU<SUSU<SUSU<S3 5 UR 5 UR [ R"US 5U5 UR [ R"US 5U5 UR [ R"US 5U5 g) NIFDzif True: import os import threading import time done = False def notify_fini(): global done done = True os.write(z, z) t.join() threading._register_atexit(notify_fini) def task(): while not done: time.sleep(0.1) os.write(z\) t = threading.Thread(target=task) t.start() os.write() r;)rrcreateexecrrrr)r6r_interpw_interpINTERPFINIDONEinterps rtest_threads_join_with_no_main6SubinterpThreadingTests.test_threads_join_with_no_mains!YY[$$& #2dX.#2dX.Zr&, + .   1-v6 1-t4 1-t4r!c2[S5 S[RRS3nSU<S3n[RR 5 [ SU5up4nSSS5 UR SWR55 g!,(df  N/=f)Nrzif 1: import os import threading import time def f(): # Make sure the daemon thread is still running when # Py_EndInterpreter is called. time.sleep(zJ) threading.Thread(target=f, daemon=True).start() zKif 1: import _testcapi _testcapi.run_in_subinterp(rr@z:Fatal Python error: Py_EndInterpreter: not the last thread)r rrr)SuppressCrashReportr rr)r6subinterp_coder^rDrErFs rtest_daemon_threads_fatal_error7SubinterpThreadingTests.test_daemon_threads_fatal_errorsk"!LL6678  " $ \\ - - /0v>LBS0 ,-0ZZ\ ;0 /s B BTFalloweddaemon_allowedr(c [S5 [R"SUSUS35n[[R 5n[R"SU<SUSUSUS 3 5n[ RR5 [S U5u pSSS5 U R5$!,(df  W R5$=f) N_testinternalcapiz import test.support import threading def func(): print('this should not have run!') t = threading.Thread(target=func, daemon=rz# t.start() zh import test.support test.support.run_in_subinterp_with_config( z, use_main_obmalloc=True, allow_fork=True, allow_exec=True, allow_threads=z', allow_daemon_threads=z0, check_multi_interp_extensions=z;, own_gil=False, ) r@) r rNrOboolrPy_GIL_DISABLEDrrr r) r6 before_startrrr(rcheck_multi_interp_extensionsr^rrFs r_check_allowed&SubinterpThreadingTests._check_allowed.s )*!.6 7=X> N *)-W-D-D(E%& "# 'i(&&4%56//L.MN  " \\ - - /(v6IAq0zz|0 /zz|s B,, C cJURSSSS9nURSU5 g)NFrr)rrr6rFs rtest_threads_not_allowed0SubinterpThreadingTests.test_threads_not_allowedOs0!! "  nc*r!c>URS5 URSSSS9nURSU5 SSS5 URS5 URSSSSS9nURSU5 SSS5 g!,(df  NM=f!,(df  g=f)Nz via Thread()TFrrzvia Thread.daemon setterzt.daemon = True)rrrrs rtest_daemon_threads_not_allowed7SubinterpThreadingTests.test_daemon_threads_not_allowedXs \\. )%%$&C MM.# . *\\4 5%%!$ &C MM.# .6 5* )6 5s$A=%B= B  BrKN)r)rFrGrHrIrrrr%rrrrrrrJrKr!rrrsw.8#.J#5#5J;;.#&*#B++//r!rcp\rSrSrSrSrSrSrSr\ "5S5r Sr S r S r S rS rS rSrg)ThreadingExceptionTestsilc[R"5nUR5 UR[UR5 UR 5 grC)r*rRrrrrr6rs rtest_start_thread_again/ThreadingExceptionTests.test_start_thread_againos6!!#  , 5 r!cn[R"5nUR[UR5 grC)r*rrrr)r6rs rtest_joining_current_thread3ThreadingExceptionTests.test_joining_current_threadus&"113 ,(;(;*PQ /r!cSn[SU5up#nURUS5 UR5nURSU5 URSU5 URSU5 UR SU5 g)Naif True: import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() r@r!Exception in thread"Traceback (most recent call last):ZeroDivisionErrorUnhandled exceptionr rrrrrys rtest_print_exception,ThreadingExceptionTests.test_print_exceptionst$(f5  c"jjl +S1 :C@ )3/ .4r!cSn[SU5up#nURUS5 UR5nURSU5 URSU5 URSU5 UR SU5 g)Naif True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) sys.stderr = None running = False t.join() r@r!rrrrrrys r%test_print_exception_stderr_is_none_1=ThreadingExceptionTests.test_print_exception_stderr_is_none_1st((f5  c"jjl +S1 :C@ )3/ .4r!cSn[SU5up#nURUS5 URSUR55 g)Naif True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 sys.stderr = None t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() r@r!r)r rrrrys r%test_print_exception_stderr_is_none_2=ThreadingExceptionTests.test_print_exception_stderr_is_none_2sB((f5  c" . =r!c Sn[SU5 g)Na9if True: import time import threading import _thread def f(): try: f() except RecursionError: f() def g(): try: raise ValueError() except* ValueError: f() def h(): time.sleep(1) _thread.interrupt_main() t = threading.Thread(target=h) t.start() g() t.join() r@)r rks rtest_print_exception_gh_1020566ThreadingExceptionTests.test_print_exception_gh_102056s6 dF+r!c^Sm"U4SjS[R5nU"5nUR5 UR5 UR UR 5 UR UR [5 SUlg)NcerCrKrKr!r bare_raiseOThreadingExceptionTests.test_bare_raise_in_brand_new_thread..bare_raises r!c&>\rSrSrSrU4SjrSrg)OThreadingExceptionTests.test_bare_raise_in_brand_new_thread..Issue27558iNcP>T"5 g![anXlSnAgSnAff=frC)r$exc)r6rrs rrbSThreadingExceptionTests.test_bare_raise_in_brand_new_thread..Issue27558.runs$#L #"HH#s % %)r)rFrGrHrIrrbrJ)rsr Issue27558rsC # #r!r)r*rRrrrrrr)r6rrrs @r#test_bare_raise_in_brand_new_thread;ThreadingExceptionTests.test_bare_raise_in_brand_new_threadsb  #)) #   VZZ( fjj,7 r!cSnUR[R[R5 [ S5Vs/sHn[ R "US9PM nnUH#nUR5 UR5 M% gs snf)Nc[[RSSS9nURS5 [R "5 SSS5 g!,(df  g=f)Nrr)encoding )openrTESTFNwrite traceback format_stack)fps r modify_fileQThreadingExceptionTests.test_multithread_modify_file_noerror..modify_file.s9i&&g>" &&(?>>s 'A  ArRr) r(runlinkrrr*rRrr)r6r rrrs r$test_multithread_modify_file_noerror5 600>565:>2,>*r!rc\rSrSrSrSrg) ThreadRunFaili=c[S5e)N run failedrr5s rrbThreadRunFail.run>s &&r!rKNrrKr!rrr=s'r!rc~^\rSrSrU4Sjr\S5r\R\S55r Sr Sr Sr Sr S rU=r$) ExceptHookTestsiBc8>[U5 [TU] 5 grC)r-superrj)r6 __class__s rrjExceptHookTests.setUpCs"4(  r!c[R"S5n[SS9nUR5 UR 5 SSS5 WR 5R 5nURSWRS3U5 URSU5 URSU5 URSU5 g!,(df  N=f) Nrexcepthook threadrPException in thread : #Traceback (most recent call last): z raise ValueError("run failed")zValueError: run failed) rcaptured_outputrrrgetvaluerNrrQ)r6rrs rtest_excepthookExceptHookTests.test_excepthookGs  $ $X .&"(;> C cB[R"S5n[S5e![aWn[R "/[ R"5QSP5n[R"U5 SnSnAO!Snf=fSnAff=fSSS5 O!,(df  O=fWR5R5nURS[R"5S3U5 URSU5 URSU5 URSU5 g)Nrbugrr r!z raise ValueError("bug")zValueError: bug) rr"rr$r*ExceptHookArgsrexc_infor'r#rNrr)r6rrrs rtest_excepthook_thread_None+ExceptHookTests.test_excepthook_thread_NoneTs  $ $X .&  ''  //0G#,,.0G$0GH ((. D4D  / . ."((* ,Y-@-@-B,C3GP .ThreadExitikc0[R"S5 gr:)rexitr5s rrb8ExceptHookTests.test_system_exit..ThreadExit.runls  r!rKNrrKr!r ThreadExitr.ks r!r2rr)r*rRrr"rrrr#)r6r2rrs rtest_system_exit ExceptHookTests.test_system_exitjsf ))   $ $X .&\F LLN KKM/ *B/ / .s (B Bc ^SmU4Sjn[R"[SU5 [5nUR 5 UR 5 SSS5 UR TR[5 UR [TR5S5 UR TRTRR5 URTRW5 Smg!,(df  N=f!Smf=f)Nc >UmgrCrK) hook_argsrs rhook4ExceptHookTests.test_custom_excepthook..hookzsDr!r'r)r swap_attrr*rrrrexc_typerr exc_value exc_traceback __traceback__rr)r6r8rrs @rtest_custom_excepthook&ExceptHookTests.test_custom_excepthookws  ""9lDA&  B   T]]J 7   S0, ?   T//1M1M N MM$++v .DBADs#C?+C.BC?. C<8C??Dc ^SnSmU4Sjn[R"[SU5 [R"[SU5 [R"S5n[ 5nUR 5 UR5 SSS5 SSS5 SSS5 URWR5S5 URTS5 g!,(df  NQ=f!,(df  NZ=f!,(df  Nc=f)Nc[S5e)Nthreading_hook failedrrs rthreading_hookCExceptHookTests.test_custom_excepthook_fail..threading_hooks45 5r!c>[U5mgrCr)r;r<r=err_strs rsys_hook=ExceptHookTests.test_custom_excepthook_fail..sys_hooks )nGr!r'rz#Exception in threading.excepthook: rC) rr:r*rr"rrrrr#)r6rDrHrrrGs @rtest_custom_excepthook_fail+ExceptHookTests.test_custom_excepthook_fails 6 %  y, G   sL( ;  $ $X .&"_F LLN KKM/<H *? A "9:/ .< ;H Gs;C5C$+CC$C5 C! C$$ C2 .C55 DcDSnSnU"5n[R"[SU5 U"5n[R[lU"5nSSS5 UR UW5 UR UW5 UR US5 g!,(df  NE=f)Nc[R"S5n[SS9nUR5 UR 5 SSS5 UR 5$!,(df  WR 5$=f)NrrrP)rr"rrrr#)outputrs r run_thread.run_threads[((2f&,?@  3??$ $ 32??$ $s *A A6c4[S[RS9 g)NzRunning a thread failed)file)r\rrrs rrD@ExceptHookTests.test_original_excepthook..threading_hooks +#** =r!r'zRunning a thread failed )rr:r*r+r'rr)r6rOrDdefault_outputcustom_hook_outputrecovered_outputs rtest_original_excepthook(ExceptHookTests.test_original_excepthooks % >$   y, G!+ #,#;#;I )| H )9: N,>? +-HIH Gs (B BrK)rFrGrHrIrjr r$rrr*r3r?rJrWrJ __classcell__rs@rrrBsY 8 8 11( 0*;*JJr!rc&\rSrSrSrSrSrSrg) TimerTestsicp[RU5 /Ul[R"5UlgrC)rerj callback_argsr*rcallback_eventr5s rrjTimerTests.setUps'4 'oo/r!c[R"SUR5nUR5 URR 5 UR RS5 SURS'URR5 [R"SUR5nUR5 URR 5 UR[UR5S5 URURS04S04/5 UR5 UR5 g)NrkblahbarfoorrK)r*Timer _callback_spyrr_rrrr4rrrr^r)r6timer1timer2s r test_init_immutable_default_args+TimerTests.test_init_immutable_default_argsst'9'9:    " 6"$ e !!#t'9'9:    " T//0!4 ++r2hR-AB  r!cURRUSSUR545 URR 5 grC)r^rcopyr_r)r6rr4s rrfTimerTests._callback_spys7 !!47FKKM":; !r!)r^r_N)rFrGrHrIrjrirfrJrKr!rr\r\s0 ""r!r\c8\rSrSr\"\R 5rSrg) LockTestsirKN) rFrGrHrI staticmethodr*rlocktyperJrKr!rrorosINN+Hr!roc8\rSrSr\"\R 5rSrg) PyRLockTestsirKN) rFrGrHrIrpr*_PyRLockrqrJrKr!rrsrssI../Hr!rszRLock not implemented in Cc>\rSrSr\"\R 5rSrSr g) CRLockTestsicx[R"SS9n[R"5 SSS5 UR W/5 S04SSS04SSS04/nUHQup4UR X4S9 UR [5 [R"U0UD6 SSS5 SSS5 MS "S S UR5n[R"SS9nU"SS S 9 SSS5 UR U/5 g!,(df  N=f!,(df  Nw=f!,(df  M=f!,(df  NU=f) NT)recordrrKrr;)r;rr3c,^\rSrSrSU4SjjrSrU=r$)/CRLockTests.test_signature..CustomRLockic">[TU]5 grC)rr7)r6rrrs rr78CRLockTests.test_signature..CustomRLock.__init__s "r!rK)returnN)rFrGrHrIr7rJrYrZs@r CustomRLockrzs  # #r!r~r)r) rrr*rrr assertWarnsrrq)r6 warnings_log arg_typesrr4r~s rtest_signatureCRLockTests.test_signatures  $ $D 1\ OO 2 r*2J #qN c1X  &LD47%%&89OOT4V4:87&  #$-- # $ $D 1\ Q 2 r*+2 1:9872 1s;C7*DDDD+7 D D D D( + D9rKN) rFrGrHrIrpr*_CRLockrqrrJrKr!rrvrvsI--.H+r!rvc8\rSrSr\"\R 5rSrg) EventTestsirKN) rFrGrHrIrpr*r eventtyperJrKr!rrrsY__-Ir!rc>\rSrSr\"\R 5rSrSr g)ConditionAsRLockTestsic&URS5 g)Nz,Condition does not expose _recursion_count())rBr5s rtest_recursion_count*ConditionAsRLockTests.test_recursion_counts DEr!rKN) rFrGrHrIrpr*rrqrrJrKr!rrrsI//0HFr!rc8\rSrSr\"\R 5rSrg)ConditionTestsirKN) rFrGrHrIrpr*rcondtyperJrKr!rrrsI//0Hr!rc8\rSrSr\"\R 5rSrg)SemaphoreTestsirKN) rFrGrHrIrpr* SemaphoresemtyperJrKr!rrrs9../Gr!rc8\rSrSr\"\R 5rSrg)BoundedSemaphoreTestsirKN) rFrGrHrIrpr*rrrJrKr!rrrs9556Gr!rc8\rSrSr\"\R 5rSrg) BarrierTestsirKN) rFrGrHrIrpr*Barrier barriertyperJrKr!rrrsy001Kr!rc\rSrSrSrSrg) MiscTestCasei c^[U5 S1nSS1n[R"U[SXS9 g)Nr2rr)r*r)extra not_exported)r-r check__all__r*)r6rrs r test__all__MiscTestCase.test__all__ s4"4('7 T9.F#( Er!rKN)rFrGrHrIrrJrKr!rrr sEr!rcx\rSrSrSrSr\"S5S5rSrSr Sr S r \ RS 5rS rg ) InterruptMainTestsicSn[R"X5nUR[RX5 UR[5 [R "5 SSS5 g!,(df  g=f)NcSS- g)Nr;rrK)signumrs rhandlerLInterruptMainTests.check_interrupt_main_with_signal_handler..handlers aCr!)signalr(rrrinterrupt_main)r6rr old_handlers r(check_interrupt_main_with_signal_handler;InterruptMainTests.check_interrupt_main_with_signal_handlersP mmF4   v;   0 1  " " $2 1 1s A.. A<c[R"U5n[R"U[R5 [R"U5 [R"U[R 5 [R"U5 [R"X5 g![R"X5 f=frC)r getsignalSIG_IGNrrSIG_DFL)r6rrs rcheck_interrupt_main_noerror/InterruptMainTests.check_interrupt_main_noerror!sr""6* + MM&&.. 1  " "6 * MM&&.. 1  " "6 * MM& *FMM& *s A6B%%B=z*gh-118433: Flaky due to a longstanding bugcSn[R"US9nUR[5 UR 5 UR 5 SSS5 UR 5 g!,(df  N=f)Nc.[R"5 grC)rrrKr!rcall_interruptHInterruptMainTests.test_interrupt_main_subthread..call_interrupt2s  " " $r!r)r*rRrKeyboardInterruptrr)r6rrs rtest_interrupt_main_subthread0InterruptMainTests.test_interrupt_main_subthread.sQ %   N 3   0 1 GGI FFH2 2 1s !A'' A5cUR[5 [R"5 SSS5 g!,(df  g=frC)rrrrr5s rtest_interrupt_main_mainthread1InterruptMainTests.test_interrupt_main_mainthread:s+  0 1  " " $2 1 1s 5 AcUR[R5 UR[R5 grC)rrSIGINTSIGTERMr5s r'test_interrupt_main_with_signal_handler:InterruptMainTests.test_interrupt_main_with_signal_handler@s& 55fmmD 55fnnEr!cUR[R5 UR[R5 grC)rrrrr5s rtest_interrupt_main_noerror.InterruptMainTests.test_interrupt_main_noerrorDs& ))&--8 ))&..9r!cUR[[RS5 UR[[R[R 5 UR[[RS5 g)Nri@B)rrrrrNSIGr5s r"test_interrupt_main_invalid_signal5InterruptMainTests.test_interrupt_main_invalid_signalHsN *g&<&.workerSs?$JGAJq'!OJ q'' "KNr!rr)r*rRrrr)r6rrrrers rtest_can_interrupt_tight_loops1InterruptMainTests.test_can_interrupt_tight_loopsMssv'g  "   F$0L M  !* !**Q   A'r!rKN)rFrGrHrIrrrrrrrrr reap_threadsrrJrKr!rrrsW% +FG H % F:G ""(#(r!rc&\rSrSrSrSrSrSrg) AtexitTestsigc[SS5upnURU5 URUR5S5 g)Nr@zif True: import threading def run_last(): print('parrot') threading._register_atexit(run_last) sparrot)r rrrNrCs rtest_atexit_outputAtexitTests.test_atexit_outputis='/    i0r!cD[SS5upnURU5 g)Nr@aNif True: import threading from unittest.mock import Mock mock = Mock() threading._register_atexit(mock) mock.assert_not_called() # force early shutdown to ensure it was called once threading._shutdown() mock.assert_called_once() )r rrCs rtest_atexit_called_once#AtexitTests.test_atexit_called_oncevs'' /   r!c[SS5upnURU5 URSUR55 g)Nr@zif True: import threading def func(): pass def run_last(): threading._register_atexit(func) threading._register_atexit(run_last) z2RuntimeError: can't register atexit after shutdown)r rrrrCs rtest_atexit_after_shutdown&AtexitTests.test_atexit_after_shutdowns?( /    J  r!rKN)rFrGrHrIrrrrJrKr!rrrgs 1 r!r__main__)C test.supportrrrrrrrtest.support.import_helperr test.support.script_helperr r r r[rrr*r^rrrrrrNr rr rrrrZrequires_working_threadingrr r%r-rr/rRrMTestCasererrrerrrrr\ro RLockTestsrsr#rrvrrrrrrrrrrFrrKr!rrsQ TT994N,    )++48 + = 4 f<!!