WSGI support (was [Twisted-web] Re: status of Twisted Web and Web 2)

Phil Christensen phil at bubblehouse.org
Thu Mar 6 14:23:13 EST 2008


On Mar 6, 2008, at 2:06 PM, Manlio Perillo wrote:
>> It's just as easy to write a Deferred-using asynchronous  
>> application as a blocking one.
>> The real issue is that a "proper" WSGI app gets informed of it's  
>> environment by the wsgi.multithreaded and wsgi.multiprocess environ  
>> variables, so if you really wanted a write-once-run-anywhere, you'd  
>> need to be able to handle both scenarios.
>
> By the way, some time ago I proposed a wsgi.asynchronous enviroment  
> variable.

Yeah, I guess that would be ideal. I guess I was assuming that if it's  
neither multiprocess or multithreaded, then it must be asynchronous,  
but now that I think about it, that's obviously not the case...

I've heard the WSGI guys are kind of hard to talk to about feature  
requests and the like, but I've never really dealt with them...

>> As far as Twisted's WSGI implementation, it should probably support  
>> both approaches, maybe where some kind of argument to the  
>> WSGIResource class constructor determines what it specifies in the  
>> environ dictionary. It should be the responsibility of the WSGI  
>> application itself to do the right thing depending on what's inside  
>> the environ dict.
>
> I'm not sure that this is possible.
> An application is asynchronous or synchronous.
>
> The problem arises when one have to implement a reusable middleware.

Yeah, I guess that's also true. I think my main point was that since  
there's a number of different programming practices that would be  
problematic in a particular type of container, it's the responsibility  
of the application to do the right thing, whatever the case may be.

>> Also, as an aside, I have recently ported web2's WSGI support back  
>> to web1, and am using it on a production site with much success.  
>> I'd like to contribute it, but I have little to no time to  
>> participate in the Twisted review process. Anyone who would like a  
>> copy is welcome to it, however...
>
> I'm interested in code that can help me to write a WSGI  
> implementation for web1, thanks!

I've attached it to a ticket I created awhile back here:

	http://twistedmatrix.com/trac/ticket/2753

Although the ticket description talks about a web2 dependency, the  
second attachment is the most recent version, which has no such  
dependency.

-phil



More information about the Twisted-web mailing list