Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.

This prevents unpredictable aborts in Py_EndInterpreter() when some non-daemon threads are still running.
This commit is contained in:
Antoine Pitrou 2013-09-07 23:38:37 +02:00
parent eda7c64151
commit 7b4769937f
7 changed files with 223 additions and 33 deletions

View file

@ -208,6 +208,8 @@ new_threadstate(PyInterpreterState *interp, int init)
tstate->trash_delete_nesting = 0;
tstate->trash_delete_later = NULL;
tstate->on_delete = NULL;
tstate->on_delete_data = NULL;
if (init)
_PyThreadState_Init(tstate);
@ -390,6 +392,9 @@ tstate_delete_common(PyThreadState *tstate)
if (tstate->next)
tstate->next->prev = tstate->prev;
HEAD_UNLOCK();
if (tstate->on_delete != NULL) {
tstate->on_delete(tstate->on_delete_data);
}
PyMem_RawFree(tstate);
}