diff Python/pystate.c @ 85598:d52b68edbca6

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.
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 07 Sep 2013 23:38:37 +0200
parents 1edff836c954
children 3ce0102e4c1f
line wrap: on
line diff
--- a/Python/pystate.c	Sat Sep 07 14:12:55 2013 -0700
+++ b/Python/pystate.c	Sat Sep 07 23:38:37 2013 +0200
@@ -208,6 +208,8 @@
 
         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 @@
     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);
 }