[Web-SIG] Direct use of sys.stdout, sys.stderr and sys.stdin in WSGI application.

Graham Dumpleton graham.dumpleton at gmail.com
Thu Mar 22 22:11:26 CET 2007

On 23/03/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 04:52 PM 3/22/2007 +0000, Alan Kennedy wrote:
> >But if the users want their "modern" python applications to be
> >portable everywhere on WSGI, e.g. returning (iterable) files as ouput,
> Actually, returning a file as output is a horrible idea, since it will
> massively reduce throughput, due to transmitting one line at a time to the
> web browser.  :)

FWIW, in mod_wsgi I have a directive which allows one to optionally
override the prescribed WSGI behaviour of flushing after every chunk
returned. Instead, the data gets buffered up by Apache and written as
a large block rather than small blocks. Obviously you cant use this if
you intend streaming data and probably not a good idea if something is
returning a huge amount of data, but added it if for some reason you
are using some third party WSGI component which is written in a sloppy
way and generates lots of small blocks and you cant change it easily
or quickly. With minimal effort the directive allows you to quickly
improve throughput while you perhaps address the issues in the WSGI
component or add on top your own middleware component which does the
buffering in some other way which suits the actual application better.


More information about the Web-SIG mailing list