[Twisted-web] A more Twisted approach to async apps in WSGI

William Dode wilk-ml at flibuste.net
Thu Sep 23 02:33:33 MDT 2004


"Phillip J. Eby" <pje at telecommunity.com> writes:

> Hi all.  I've been away for a few days due to loss of e-mail service
> when my dedicated server lost a hard drive.  Unfortunately my ISP
> didn't support the OS version any more, so I had to rebuild everything
> for the new OS version.
>
> Anyway, on to the topic of my post.  Should 'wsgi.input' become an
> iterator?  Or should we develop a different API for asynchronous
> applications?
>
> On the positive side of the iterator approach, it could make it easier
> for asynchronous applications to pause waiting for input, and it could
> in principle support "chunked" transfer encoding of the input stream.
>
> However, since we last discussed this, I did some Googling on CGI and
> chunked encoding.  By far and away, the most popular links regarding
> chunked encoding and CGI, are all about bugs in IIS and Apache leading
> to various vulnerabilities when chunked encoding is used.  :(
>
> Once you get past those items (e.g. by adding "-IIS -vulnerability" to
> your search), you then find *our* discussion here on the Web-SIG!
> Finally, digging further, I found some 1998 discussion from the IPP
> (Internet Printing Protocol!) mailing list about what HTTP/1.1 servers
> support chunked encoding for CGI and which don't.
>
> Anyway, the long and short of it is that CGI and chunked encoding are
> quite simply incompatible, which means that relying on its
> availability would be nonportable in a WSGI application anyway.

I don't understand the problem with an iterator on CGI. A CGI script is
by definition multi-process. If one block, a new script will be run and
anyway the first client will wait... If no one block, an iterator or not
will not change anything for him.

It will be up to the server to decide if he can use chunked encoding or
not. If the script block and doesn't use chunked encoding, it will be
not possible to run the script in cgi anyway... I know people who use
chunked encoding in cgi, they know what they do and it's fine, i'm sure
they will use iterator.

I don't see the difference between

[sleep...]
[sleep...]
[sleep...]
return data

and 

[sleep...]
yield
[sleep...]
yield
[sleep...]
yield

for a cgi script if it's not possible to don't sleep.

-- 
William Dodé - http://flibuste.net



More information about the Twisted-web mailing list