[Web-SIG] WSGI and asyncronous applications support

Manlio Perillo manlio_perillo at libero.it
Tue Sep 18 13:39:23 CEST 2007


Hi.

I have read some old posts about asynchronous applications support in WSGI:

http://comments.gmane.org/gmane.comp.python.twisted.web/2561?set_lines=100000
http://comments.gmane.org/gmane.comp.python.twisted.web/632?set_lines=100000


Since nginx *does* not supports threads, it is important to add 
extensions to WSGI to support asynchronous applications.


There are two solutions:
1) The applications returns something like environ['wsgi_not_yet_done']
    and produce its output using the write callable, and the finish
    callable when its done
2) The applications calls resume = environ['wsgi.pause_output'](), yield
    an empty strings, and then calls resume() to notify the server that
    it can call .next() again



1) should be very simple to implement, and it is easy to understand how 
to use it.

As an example, we can use some API that calls a callback function when 
the result is available:
conn.execute("SELECT * FROM test", query_callback)

def query_callback(row):
    write(row[...])


2) Can be implemented in mod_wsgi, however my problem is that I can't 
figure out how the application can yield some data available after a 
callback is called.



Thanks  Manlio Perillo


More information about the Web-SIG mailing list