[mod_python] O/S SendFile call

Oliver Nelson flxkid at techemail.com
Fri Feb 6 12:31:05 EST 2004


Thanx for the tip.  Had 3.1.2b2 or something and it wasn't working.  Went to the CVS and found some notes that your patch had been changed from write_file to sendfile.  Just FYI.

Thanx again,


--- Conrad Steenberg <conrad at hep.caltech.edu> wrote:
Hi Oliver

The request class in newer versions (3.1b2+ I think) has a write_file
method that you can use as follows:

# First init the offset and bytes variables, then:
    while bytes>0:
      if sent<0: raise OSError(5,"Error sending file")
    # handle error
  return apache.OK



On Wed, 2004-02-04 at 22:16, Oliver Nelson wrote:
> I read in the apache docs that if possible you should try and have an O/S version that has the sendfile call so that apache doesn't have to do a read and a send of files.
> I am writing a python handler that has to go out on a network, find a file and then pass then return that file to the client browser.  Right now I'm reading in the file and then writing it the output stream.  It seems that there should be a much better way to do this like apache does it with sendfile.  Is it possible to use this (the sendfile os call) from inside my python handler?
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
Conrad Steenberg <conrad at hep.caltech.edu>
Conrad Steenberg <conrad at hep.caltech.edu>

More information about the Mod_python mailing list