File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Lib/test/test_interpreters Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -691,7 +691,7 @@ def test_remaining_daemon_threads(self):
691
691
import time
692
692
693
693
def task():
694
- time.sleep(100 )
694
+ time.sleep(3 )
695
695
696
696
threads = [threading.Thread(target=task, daemon=True) for _ in range(3)]
697
697
for t in threads:
Original file line number Diff line number Diff line change @@ -2449,14 +2449,17 @@ Py_EndInterpreter(PyThreadState *tstate)
2449
2449
_Py_FinishPendingCalls (tstate );
2450
2450
2451
2451
_PyAtExit_Call (tstate -> interp );
2452
- _PyRuntimeState * runtime = interp -> runtime ;
2453
- _PyEval_StopTheWorldAll (runtime );
2454
- PyThreadState * list = _PyThreadState_RemoveExcept (tstate );
2455
-
2452
+ _PyEval_StopTheWorld (interp );
2456
2453
/* Remaining daemon threads will automatically exit
2457
2454
when they attempt to take the GIL (ex: PyEval_RestoreThread()). */
2458
2455
_PyInterpreterState_SetFinalizing (interp , tstate );
2459
- _PyEval_StartTheWorldAll (runtime );
2456
+
2457
+ PyThreadState * list = _PyThreadState_RemoveExcept (tstate );
2458
+ for (PyThreadState * p = list ; p != NULL ; p = p -> next ) {
2459
+ _PyThreadState_SetShuttingDown (p );
2460
+ }
2461
+
2462
+ _PyEval_StartTheWorld (interp );
2460
2463
_PyThreadState_DeleteList (list , /*is_after_fork=*/ 0 );
2461
2464
2462
2465
// XXX Call something like _PyImport_Disable() here?
You can’t perform that action at this time.
0 commit comments