[Web-SIG] [extension] x-wsgiorg.flush

Phillip J. Eby pje at telecommunity.com
Thu Oct 4 16:37:58 CEST 2007


At 03:53 PM 10/4/2007 +0200, Manlio Perillo wrote:
>Phillip J. Eby ha scritto:
> > At 10:57 AM 10/4/2007 +0200, Manlio Perillo wrote:
> >> Phillip J. Eby ha scritto:
> >> > [...]
> >> >> 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.  :)
> >> >
> >>
> >> 07-Dec-2003!
> >> And yet it seems that WSGI is not pervasively used.
> >
> > What do you mean?  Can you name a popular Python web framework or
> > library that doesn't either use or support WSGI?
> >
>
>Django, as an example, uses WSGI "only as a backend".

That's still WSGI *support*.


>Django design is not based on WSGI, it is WSGI that is adapted for Django.

Yep - which is why we need WSGI 2.  WSGI 1 achieved all its goals 
*except* for being easy to write middleware and build frameworks on 
it.  It should be easier to use WSGI than to not use it.


> > That won't be possible in WSGI 2.0 - it's a purely synchronous API.
>
>This is the reason why I don't like WSGI 2.0 :).
>
>However I have to admit that developing a full asynchronous application
>is not easy, notably when we have to interact with a database and a
>transaction.

Right - in practice, there is not enough of a common async API for 
Python to make it practical to implement asynchronousness in WSGI 
itself.  At least, in the last three years nobody has made a 
practical proposal for it.  In practice, if you want to write a 
fully-async web app you must use Twisted or a similar framework and 
commit to using its API.  You can of course still use WSGI 
components, but your application will not be able to run on a server 
that doesn't provide your async framework's API.


>It is really so hard to implement WSGI 1.0 and to write middlewares for it?

Absolutely.  Most of the time I see someone post example middleware 
code, it is not WSGI compliant in some fashion.


>I think that WSGI 2.0 should simply correct some problems in WSGI 1.0,

The single biggest problem in WSGI 1.0 is start_response() and 
write().  They were hacks to support legacy applications and frameworks.


>It's very unfortunate that the WSGI implementation in Twisted just uses
>threads instead of doing some experimentation.

You're making the assumption that no experimentation was done.  Check 
the Web-SIG archives from three years ago and see the discussions 
about async APIs.



More information about the Web-SIG mailing list