[mod_python] Re: Another threading issue: chdir (fwd)

Gregory Trubetskoy grisha at modpython.org
Mon Jun 12 17:30:14 EST 2000


On Mon, 12 Jun 2000, Stéphane Bidoul wrote:

> >The more I think about this, the more it seems to me that doing away with
> >the chdir and prepending the path rather than the '.' is the way to go.
> 
> Agreed, but I wonder how much the manipulation of sys.path to do the imports
> can cause threading issues... Is it possible to avoid it?

You could avoid it by making sure that the Pythonpath includes the
directory where your handlers are from the start, for example by setting
PYTHONPATH in the Apache startup script. But if we're going this route, we
might as well abandon the multiple interpreters.

Another problem with this is that typically you'll have to be root on the
system to restart Apache, and in many cases users are not.

On the upside, sys.path shouldn't get manipulated more than once. An
interpreter will get created and the sys.path changed upon the first hit,
after that it won't change. The sys.path manipualtion should be surrounded
by Python locks.

I have another idea - unless I'm missing something obvious, the way to
deal with this would be to add the directory to the path at interpreter
creation time in mod_python.c.

Grisha





More information about the Mod_python mailing list