[mod_python] Question about write method of mp_request objects

Graham Dumpleton graham.dumpleton at gmail.com
Thu Jul 16 20:49:03 EDT 2009


2009/7/17 Evan Klitzke <evan at eklitzke.org>:
> Hi all,
>
> I've been profiling a mod_python app using cProfile. In the cProfile
> data, I'm noticing that on some slow requests the write() method on
> the mp_request object is taking up a lot of time.
>
> My question is: does the write() method actually include the time sent
> sending data over the wire to the client, or is it just some sort of
> memory copy into the request object, which gets flushed and sent to
> the client further down the line? If the write() method takes a long
> amount of time to send a reasonable amount of data, does it indicate
> that something weird is going on in mod_python, or just that the
> consuming client is slow?

It depends a bit on what Apache output filters are registered and how
write() is called. By default write() will automatically attempt to
flush data. So if argument not supplied to say don't flush, then yes,
would count time to send data.

That said, some output filters may buffer output data for some reason
and so flush request would be ignored. If no such buffering output
filters are registered for the request, then it will make it down to
the core output filter and would only return once all data is written
or socket error occurs.

Graham


More information about the Mod_python mailing list