summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-09-07 21:38:37 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-09-07 21:38:37 (GMT)
commit7b4769937fb612d576b6829c3b834f3dd31752f1 (patch)
tree274bf4dd801bd8ffdc066658ec63c1f9cecb3afa /Python/pystate.c
parenteda7c641515f8af1f8700634b93eba859967379c (diff)
downloadcpython-7b4769937fb612d576b6829c3b834f3dd31752f1.zip
cpython-7b4769937fb612d576b6829c3b834f3dd31752f1.tar.gz
cpython-7b4769937fb612d576b6829c3b834f3dd31752f1.tar.bz2
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.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 924b6a2..ecd00ce 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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);
}