[Web-SIG] WSGI uses

Ian Bicking ianb at colorstudy.com
Thu Aug 19 06:50:54 CEST 2004


I was playing around with making a WSGI server, and I'm starting to 
think that some really neat stuff could be done with middleware.

For instance, I was thinking about setting up something for Medusa with 
WSGI.  But though I think asynchronous code seems like a good server 
architecture, I'm not that interested in it for applications.  But this 
iteration of the WSGI spec allows for async pretty well; you can tell 
you are in that situation when wsgi.multiprocess is false and 
wsgi.multithread is false, and the iterator output can produce the data 
fairly well.

I then realized that threading itself could be a piece of middleware -- 
you just have to do the proper buffering with input and output.  An 
intelligent application that realizes it can't run as an async process 
could install this middleware itself when necessary.

Even multiprocess could really be implemented as a piece of middleware, 
either running CGI scripts, or forking worker processes.  It could get 
out of hand if every application in a multi-application system had its 
own middleware; but the extension mechanism could also allow you to 
lazily implement these models, providing callbacks to access existing 
thread or worker process pools.

Another useful piece of middleware would be something for error 
reporting; it would basically pass everything through, but wrap 
everything in try:except:.  Then you could develop and plug a nice 
debugger into whatever architecture, and the basic server can do just 
the most minimal error logging (basically print a traceback to the error 
log).

Anyway, I'm pretty excited about the possibilities.

-- 
Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org


More information about the Web-SIG mailing list