Author neologix
Recipients bquinlan, dmalcolm, jnoller, kristjan.jonsson, lukasz.langa, neologix, pitrou, sandro.tosi, ysj.ray
Date 2011-04-26.08:24:20
SpamBayes Score 1.66533e-15
Marked as misclassified No
Message-id <BANLkTimiTTG+41f8tHuMsGyvY5uLRp13pA@mail.gmail.com>
In-reply-to <1303767573.16.0.846282359543.issue10517@psf.upfronthosting.co.za>
Content
> 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).
History
Date User Action Args
2011-04-26 08:24:22neologixsetrecipients: + neologix, bquinlan, pitrou, kristjan.jonsson, jnoller, dmalcolm, sandro.tosi, ysj.ray, lukasz.langa
2011-04-26 08:24:21neologixlinkissue10517 messages
2011-04-26 08:24:20neologixcreate