Charles-Francois Natali <neolo...@free.fr> added the comment: > Not necessarily. You can have several interpreters (and therefore several > thread states) in a single thread, using Py_NewInterpreter(). It's used by > mod_wsgi and probably other software. If you overwrite the old value with the > new one, it may break such software. >
OK, I didn't know. Better not to change that in that case. > Would it be possible to cleanup the autoTLS mappings in PyOS_AfterFork() > instead? > Well, after fork, all threads have exited, so you'll be running on the behalf of the child process' main - and only - thread, so by definition you can't access other threads' thread-specific data, no? As an alternate solution, I was thinking of calling PyThread_delete_key_value(autoTLSkey) in the path of thread bootstrap, i.e. starting in Modules/_threadmodule.c t_bootstrap. Obviously, this should be done before calling _PyThreadState_Init, since it can also be called from Py_NewInterpreter. The problem is that it would require exporting autoTLSkey whose scope is now limited to pystate.c (we could also create a small wrapper function in pystate.c to delete the autoTLSkey, since it's already done in PyThreadState_DeleteCurrent and PyThreadState_Delete). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10517> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com