per interpreter storage for C extensions

Chris Mellon arkanes at gmail.com
Thu Dec 28 12:18:31 EST 2006


On 12/28/06, Robin Becker <robin at reportlab.com> wrote:
> Robin Becker wrote:
> > Chris Mellon wrote:
> >> On 12/28/06, Robin Becker <robin at reportlab.com> 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
> >
>
> ....... reading further along those lines it seems there may be some hope of
> storing this stuff on the extension module (probably where it should belong) as
> it seems that new interpreters share extensions, but when the extension is first
>   imported a shallow copy is made of the module dict. That would seem to imply
> the  extension's module is private to each interpreter.
> --


It looks like you can figure out which interpreter you're running
under by looking at PyThreadState_Get()->interp. You can key your
cache using this pointer and you should be fine, if you want to keep
it in C.

> Robin Becker
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list