[mod_python] Bug?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Fri Jun 11 19:00:03 EDT 2004


Changing current working directory is not thread-safe because if thread A
assumes that the cwd is /x and thread B changes it to /y then thread A
will be in trouble. So calling chdir() in a multithreaded program is a
no-no.

All mutlithreaded programs do not relay on current working directories for
anything. Apache can't use the DocumentRoot because there can be more than
one DocumentRoot in a single httpd process.

HTH,

Grisha

On Tue, 8 Jun 2004, Jon-Pierre Gentil wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Gregory Bond wrote:
>
> >>I am curious...why is os.curdir() /?
> >
> >
> > Because a threaded apache might have several mod_python apps running
> > concurrently and they can't all have their own CWD!
>
> I don't really see why threading makes a difference for the CWD.  A
> thread doesn't care any more than a fork about the CWD.
>
> > And there is not necessarily a 1-1 relationship between URLs and
> directories.
>
> No, but there IS a known DocumentRoot at the time of execution.  I was
> curious as to why the CWD was set to / instead of DocumentRoot.  I'm
> currently doing this for each and every function:
> os.chdir(req.document_root()).  A bit annoying to have to copy the code
> over and over again.  I was just wondering if it could be a part of the
> publisher code, mayhaps with a new PythonOption flag to keep backwards
> compatability.
>
> - --
> ::  Jon-Pierre Gentil
> ::  PGP Key ID 0xA21BC30E
> ::  Jabber: jgentil at jabber.org
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkDF4doACgkQOrVFmaIbww4kEACfS58czSl1NrWzlzpudHA/Dki0
> TFsAnRr4AdhR03DahuLOn7bcKuyHNlzb
> =iZor
> -----END PGP SIGNATURE-----
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list