[Web-SIG] [extension] x-wsgiorg.flush
graham.dumpleton at gmail.com
Thu Oct 4 04:30:28 CEST 2007
On 04/10/2007, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 09:52 PM 10/3/2007 +0200, Manlio Perillo wrote:
> >Phillip J. Eby ha scritto:
> > > [...]
> > >
> > > Now that I understand what this is for, I can explain why a WSGI
> > > extension is not necessary to provide this feature. In a compliant WSGI
> > > gateway, yielding an empty string from 'a-generator' is sufficient to
> > > "flush" the WSGI pipeline.
> > >
> >But the WSGI pipeline should already be flushed for every string
> >yielded, right?
> >An interesting "extension" for an asynchronous WSGI gateway is to
> >"suspend" the iteration when an empty string is returned, creating a
> >timer that fires after 0 milliseconds (in Twisted, this is the same as
> >callLater(0, ...))
> > > I suggest that you read this section of the spec more carefully:
> > >
> > > http://www.python.org/dev/peps/pep-0333/#buffering-and-streaming
> > >
> >There is a problem here: a WSGI gateway is not allowed to send headers
> >until the app_iter yields a non empty string or the iterator is exausted.
> Argh. You're right. I forgot about that bit. It has been a few too
> many years since I worked on the spec. :)
The actual wording of the PEP does though suggest that if one calls
write() returned from start_response() that one would flush headers.
Ie., the requirement for a non-empty string is really only mentioned
in reference to value returned from iterable and not in relation to
empty data string passed to write().
I am not sure I understand the importance of being strict and not
flushing headers until the first non-empty content data block. Was
there a specific reasoning or use case behind saying that?
More information about the Web-SIG