WSGI safe write callable using greenlet

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

WSGI safe write callable using greenlet

Manlio Perillo-3
Hi.

In this period I'm upgrading my WSGI implementation for Nginx:
http://hg.mperillo.ath.cx/nginx/ngx_http_wsgi_module/

I'm not only updating the code to work with recent Nginx versions (after
 2 years) but, above all, I'm cleaning up the code, removing stuff not
strictly required and hard to maintain.

I have already removed support to multiple Python subinterpreters, and
now I'm going to remove the async extensions I wrote (there will only
one very simple API, for applications using greenlets); finally I would
like to remove support to the write callable.

The problem, to put it simple, is that the write callable *can not* be
implemented in an asynchronous web server like Nginx.

I have two implementations:
* the first (not the default), simply keeps a buffer.
  This is explicitly forbidden by WSGI.
* the second puts the Nginx connection socket in synchronous mode;
  it works but it is something that *should not* be done.

So, I was thinking: what about a WSGI middleware that, using greenlets,
expose to the application a write callable with the correct code flow?


Here is a very first draft:
http://pastebin.com/4k1Ep4dH

It should work with every standard WSGI implementation.

I would really like to recevive feeback about this implementation, since
I have never used greenlets before.


P.S.: LICENSE is a MIT license


Thanks   Manlio
_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%40nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: WSGI safe write callable using greenlet

Manlio Perillo-3
Manlio Perillo ha scritto:

> Hi.
>
> In this period I'm upgrading my WSGI implementation for Nginx:
> http://hg.mperillo.ath.cx/nginx/ngx_http_wsgi_module/
> [...]
> So, I was thinking: what about a WSGI middleware that, using greenlets,
> expose to the application a write callable with the correct code flow?
>
>
> Here is a very first draft:
> http://pastebin.com/4k1Ep4dH
>
> It should work with every standard WSGI implementation.
>

Here is a more generic middleware and example application:
http://pastebin.com/S8c1gRfY

and here is the output:
http://pastebin.com/zzkRiRuA


The example also contains hints about features I plan to implement,
like the wsgiorg.suspend extension, and subrequests.



Regards  Manlio
_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%40nabble.com