Graham Dumpleton <graham.dumple...@gmail.com> added the comment: Except that calling it at the time of current atexit callbacks wouldn't change the current behaviour. As quoted in WEB-SIG emails the sequence is:
wait_for_thread_shutdown(); /* The interpreter is still entirely intact at this point, and the * exit funcs may be relying on that. In particular, if some thread * or exit func is still waiting to do an import, the import machinery * expects Py_IsInitialized() to return true. So don't say the * interpreter is uninitialized until after the exit funcs have run. * Note that Threading.py uses an exit func to do a join on all the * threads created thru it, so this also protects pending imports in * the threads created via Threading. */ call_py_exitfuncs(); So would need to be done prior to wait_for_thread_shutdown() or by that function before waiting on thread. The code in that function has: PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, "threading"); ... result = PyObject_CallMethod(threading, "_shutdown", ""); So calls _shutdown() on the threading module. That function is aliased to _exitfunc() method of _MainThread. def _exitfunc(self): self._stop() t = _pickSomeNonDaemonThread() if t: if __debug__: self._note("%s: waiting for other threads", self) while t: t.join() t = _pickSomeNonDaemonThread() if __debug__: self._note("%s: exiting", self) self._delete() So can be done in here. The decision which would need to be made is whether you call atexit() on all threads before then trying to join() on any, or call atexit() only prior to the join() of the thread. Calling atexit() on all possibly sounds the better option but I am not sure, plus the code would need to deal with doing two passes like that which may not may not have implications. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14073> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com