@@ -406,7 +406,7 @@ def run(self):
406
406
407
407
def test_limbo_cleanup (self ):
408
408
# Issue 7481: Failure to start thread should cleanup the limbo map.
409
- def fail_new_thread (* args ):
409
+ def fail_new_thread (* args , ** kwargs ):
410
410
raise threading .ThreadError ()
411
411
_start_joinable_thread = threading ._start_joinable_thread
412
412
threading ._start_joinable_thread = fail_new_thread
@@ -901,41 +901,6 @@ def f():
901
901
rc , out , err = assert_python_ok ("-c" , code )
902
902
self .assertEqual (err , b"" )
903
903
904
- def test_tstate_lock (self ):
905
- # Test an implementation detail of Thread objects.
906
- started = _thread .allocate_lock ()
907
- finish = _thread .allocate_lock ()
908
- started .acquire ()
909
- finish .acquire ()
910
- def f ():
911
- started .release ()
912
- finish .acquire ()
913
- time .sleep (0.01 )
914
- # The tstate lock is None until the thread is started
915
- t = threading .Thread (target = f )
916
- self .assertIs (t ._tstate_lock , None )
917
- t .start ()
918
- started .acquire ()
919
- self .assertTrue (t .is_alive ())
920
- # The tstate lock can't be acquired when the thread is running
921
- # (or suspended).
922
- tstate_lock = t ._tstate_lock
923
- self .assertFalse (tstate_lock .acquire (timeout = 0 ), False )
924
- finish .release ()
925
- # When the thread ends, the state_lock can be successfully
926
- # acquired.
927
- self .assertTrue (tstate_lock .acquire (timeout = support .SHORT_TIMEOUT ), False )
928
- # But is_alive() is still True: we hold _tstate_lock now, which
929
- # prevents is_alive() from knowing the thread's end-of-life C code
930
- # is done.
931
- self .assertTrue (t .is_alive ())
932
- # Let is_alive() find out the C code is done.
933
- tstate_lock .release ()
934
- self .assertFalse (t .is_alive ())
935
- # And verify the thread disposed of _tstate_lock.
936
- self .assertIsNone (t ._tstate_lock )
937
- t .join ()
938
-
939
904
def test_repr_stopped (self ):
940
905
# Verify that "stopped" shows up in repr(Thread) appropriately.
941
906
started = _thread .allocate_lock ()
@@ -1101,30 +1066,6 @@ def checker():
1101
1066
self .assertEqual (threading .getprofile (), old_profile )
1102
1067
self .assertEqual (sys .getprofile (), old_profile )
1103
1068
1104
- @cpython_only
1105
- def test_shutdown_locks (self ):
1106
- for daemon in (False , True ):
1107
- with self .subTest (daemon = daemon ):
1108
- event = threading .Event ()
1109
- thread = threading .Thread (target = event .wait , daemon = daemon )
1110
-
1111
- # Thread.start() must add lock to _shutdown_locks,
1112
- # but only for non-daemon thread
1113
- thread .start ()
1114
- tstate_lock = thread ._tstate_lock
1115
- if not daemon :
1116
- self .assertIn (tstate_lock , threading ._shutdown_locks )
1117
- else :
1118
- self .assertNotIn (tstate_lock , threading ._shutdown_locks )
1119
-
1120
- # unblock the thread and join it
1121
- event .set ()
1122
- thread .join ()
1123
-
1124
- # Thread._stop() must remove tstate_lock from _shutdown_locks.
1125
- # Daemon threads must never add it to _shutdown_locks.
1126
- self .assertNotIn (tstate_lock , threading ._shutdown_locks )
1127
-
1128
1069
def test_locals_at_exit (self ):
1129
1070
# bpo-19466: thread locals must not be deleted before destructors
1130
1071
# are called
0 commit comments