Message134448
> 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). |
|
Date |
User |
Action |
Args |
2011-04-26 08:24:22 | neologix | set | recipients:
+ neologix, bquinlan, pitrou, kristjan.jonsson, jnoller, dmalcolm, sandro.tosi, ysj.ray, lukasz.langa |
2011-04-26 08:24:21 | neologix | link | issue10517 messages |
2011-04-26 08:24:20 | neologix | create | |
|