Chris Mellon wrote: > On 12/28/06, Robin Becker <[EMAIL PROTECTED]> wrote: >> As part of some django usage I need to get some ReportLab C extensions into a >> state where they can be safely used with mod_python. ......... >> > > Just off the top of my head, I'd think that using thread-local storage > instead of static would work, wouldn't it? I'm not that familiar with > mod_python but I'm surely each python interpreter is in a different > thread (if not process) than the others.
I was thinking along those lines and if that were the case then I could use > PyObject* PyThreadState_GetDict() > > Return value: Borrowed reference. > Return a dictionary in which extensions can store thread-specific state > information. > Each extension should use a unique key to use to store state in the > dictionary. > It is okay to call this function when no current thread state is > available. > If this function returns NULL, no exception has been raised and the > caller should > assume no current thread state is available. Changed in version 2.3: > Previously > this could only be called when a current thread is active, and NULL meant > that > an exception was raised. I'm just not sure that your guess is true though. It seems that PyThreadState* Py_NewInterpreter() points only to the first thread. Presumably I want to initialize my extension only in one of the possibly many threads in an interpreter. I think I need something called PyObject* PyInterpreterState_GetDict() but I don't think that exists. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list