Oliver Nelson
flxkid at techemail.com
Fri Feb 6 12:31:05 EST 2004
Conrad, 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, OLIVER --- 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: try: while bytes>0: sent=0 sent=req.write_file(filename,offset,bytes) if sent<0: raise OSError(5,"Error sending file") offset=offset+sent bytes=bytes-sent except: # handle error pass return apache.OK HTH Conrad 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? > > OLIVER > _______________________________________________ > 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>
|