File tree 2 files changed +8
-50
lines changed
2 files changed +8
-50
lines changed Original file line number Diff line number Diff line change @@ -928,39 +928,6 @@ def test_debug_deprecation(self):
928
928
b'is deprecated and will be removed in Python 3.12' )
929
929
self .assertIn (msg , err )
930
930
931
- def test_import_from_another_thread (self ):
932
- # bpo-1596321: If the threading module is first import from a thread
933
- # different than the main thread, threading._shutdown() must handle
934
- # this case without logging an error at Python exit.
935
- code = textwrap .dedent ('''
936
- import _thread
937
- import sys
938
-
939
- event = _thread.allocate_lock()
940
- event.acquire()
941
-
942
- def import_threading():
943
- import threading
944
- event.release()
945
-
946
- if 'threading' in sys.modules:
947
- raise Exception('threading is already imported')
948
-
949
- _thread.start_new_thread(import_threading, ())
950
-
951
- # wait until the threading module is imported
952
- event.acquire()
953
- event.release()
954
-
955
- if 'threading' not in sys.modules:
956
- raise Exception('threading is not imported')
957
-
958
- # don't wait until the thread completes
959
- ''' )
960
- rc , out , err = assert_python_ok ("-c" , code )
961
- self .assertEqual (out , b'' )
962
- self .assertEqual (err , b'' )
963
-
964
931
965
932
class ThreadJoinOnShutdown (BaseTestCase ):
966
933
Original file line number Diff line number Diff line change @@ -1530,29 +1530,20 @@ def _shutdown():
1530
1530
1531
1531
global _SHUTTING_DOWN
1532
1532
_SHUTTING_DOWN = True
1533
+ # Main thread
1534
+ tlock = _main_thread ._tstate_lock
1535
+ # The main thread isn't finished yet, so its thread state lock can't have
1536
+ # been released.
1537
+ assert tlock is not None
1538
+ assert tlock .locked ()
1539
+ tlock .release ()
1540
+ _main_thread ._stop ()
1533
1541
1534
1542
# Call registered threading atexit functions before threads are joined.
1535
1543
# Order is reversed, similar to atexit.
1536
1544
for atexit_call in reversed (_threading_atexits ):
1537
1545
atexit_call ()
1538
1546
1539
- # Main thread
1540
- if _main_thread .ident == get_ident ():
1541
- tlock = _main_thread ._tstate_lock
1542
- # The main thread isn't finished yet, so its thread state lock can't
1543
- # have been released.
1544
- assert tlock is not None
1545
- assert tlock .locked ()
1546
- tlock .release ()
1547
- _main_thread ._stop ()
1548
- else :
1549
- # bpo-1596321: _shutdown() must be called in the main thread.
1550
- # If the threading module was not imported by the main thread,
1551
- # _main_thread is the thread which imported the threading module.
1552
- # In this case, ignore _main_thread, similar behavior than for threads
1553
- # spawned by C libraries or using _thread.start_new_thread().
1554
- pass
1555
-
1556
1547
# Join all non-deamon threads
1557
1548
while True :
1558
1549
with _shutdown_locks_lock :
You can’t perform that action at this time.
0 commit comments