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):
691691 import time
692692
693693 def task():
694- time.sleep(100 )
694+ time.sleep(3 )
695695
696696 threads = [threading.Thread(target=task, daemon=True) for _ in range(3)]
697697 for t in threads:
Original file line number Diff line number Diff line change @@ -2449,14 +2449,17 @@ Py_EndInterpreter(PyThreadState *tstate)
24492449 _Py_FinishPendingCalls (tstate );
24502450
24512451 _PyAtExit_Call (tstate -> interp );
2452- _PyRuntimeState * runtime = interp -> runtime ;
2453- _PyEval_StopTheWorldAll (runtime );
2454- PyThreadState * list = _PyThreadState_RemoveExcept (tstate );
2455-
2452+ _PyEval_StopTheWorld (interp );
24562453 /* Remaining daemon threads will automatically exit
24572454 when they attempt to take the GIL (ex: PyEval_RestoreThread()). */
24582455 _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 );
24602463 _PyThreadState_DeleteList (list , /*is_after_fork=*/ 0 );
24612464
24622465 // XXX Call something like _PyImport_Disable() here?
You can’t perform that action at this time.
0 commit comments