[mod_python] FreeBSD 5.2, mod_python 3.1.3, apache 2.0.52 .. File access problems

Robey Holderith robey at flaminglunchbox.net
Fri Oct 15 05:41:37 EDT 2004


There are some posts with similar problems, but I have yet to see a 
solution that works for me.

 From the python interpreter I can do the following:

 >>> f = file('/dev/null','w')
 >>> f.write('stuff')
 >>> f.close()

No errors, all is well.

If I do the same in a python function called by mod_python I get the 
following error:
IOError: [Errno 9] Bad file descriptor

This seems to be related to the tempdir problem reported on FreeBSD 
machines.  If I do the following in the python interpreter:

 >>> import tempfile
 >>> tempfile.gettempdir()

'/tmp' is returned as a valid temp directory.  mod_python gives me:

IOError: [Errno 2] No usable temporary directory found in ['/tmp', 
'/var/tmp', '/usr/tmp', '/']

I did a little bit of digging into this problem and found that in 
tempfile._get_default_tempdir()

_os.fdopen(fp, 'w') is throwing [Errno 22] Invalid argument

Why would something low-level like this cause problems in the mod_python 
environment but not in standard use?

thanks in advance-

Robey Holderith


More information about the Mod_python mailing list