Re: [Python-Dev] wsgi validator with asynchronous handlers/servers

Luca Sbardella <[email protected]> Tue, 26 Mar 2013 07:32:45 +0000
Newsgroups gmane.comp.python.tulip,gmane.comp.python.web
Message-ID <CAF94-jbM_w1cb7vp91ZR=85fgmTg5XO3yx+iXE2LqWsGPY0VMw@mail.gmail.com>
> i already have wsgi implementation
> https://github.com/fafhrd91/httpclient/blob/master/httpclient/server.py
>
> Great, maybe I can start by forking that project?


> wsgi app could just return Future, thats all you need to make tulip work.
>
> Returning a Future is a major departure from the spec of wsgi application
handler. It also means you need to have a full response before you start
writing back to the client. My idea was:

* still to return an iterable over bytes
* handle empty bytes so that the server handler pauses to consume the
iterable and add a callback to the event loop to resume at the next loop

This is what I do in pulsar and it is briefly documented here (the
application handler only)
http://quantmind.github.com/pulsar/apps/wsgi/intro.html#wsgi-async

The issue the current wsgi spec has it requires the application handler to
invoke the start_response callable before the iterable it returns yields
its first body bytestring. This is the case even if the bytestring it
yields is empty.

Luca