[mod_python] Serving files efficiently

Dustin Mitchell dustin at ywlcs.org
Thu May 30 21:07:34 EST 2002

On Thu, May 30, 2002 at 06:20:56PM -0700, Conrad Steenberg wrote:
> Hi
> Looking at the previous thread on serving files got me thinking:
> I'm also trying to serve a file (or part of a file) in response to an
> xmlrpc query. Since URL filtering etc. is not an option in this case, is
> there a way to tell apache to do a sendfile() or similar from
> mod_python? I'm sure this would be more efficient that my current method
> of (roughly) reading to a buffer and then sending the buffer with
> req.write() and constructing my own headers.

Since sendfile() is pretty much what Apache will do anyway, you can just call
sendfile() from Python.  There's a Python implementation of sendfile in
Medusa (I haven't tested it, but it's in the source).  You could also SWIG




  Dustin Mitchell
  dustin at ywlcs.org

More information about the Mod_python mailing list