[Web-SIG] WSGI multi threading indications?

Foobar BazBaz foobarbazbaz at yahoo.com
Mon Jan 8 21:54:13 CET 2007


--- "Phillip J. Eby" <pje at telecommunity.com> wrote:

> At 08:38 AM 1/8/2007 -0800, Foobar BazBaz wrote:
> >I'm using wsgiref.simple_server running behind
> Apache.
> >(Created using wsgiref.simple_server.make_server)
> >
> >I see:
> >   wsgi.multiprocess is False
> >   wsgi.multithread is True
> >   wsgi.run_once is False
> >
> >I'm surprised by the value of multithread, since it
> >appears
> >(and looking at the code seems to verify) that
> >additional
> >threads are never created; i.e. the server
> >synchronously
> >handles one request at a time.
> >
> >Am I missing something?
> 
> The simple_server never creates multiple threads,
> but it's potentially 
> multi-threadable.  It probably shouldn't be saying
> multithread unless it 
> knows it is.  The WSGIRequestHandler.handle() method
> is the culprit; it 
> should probably be checking self.server in some way
> and passing an 
> appropriate multithread flag to the newly created
> ServerHandler.
> 
> 

Phillip,

Yes... that's it exactly.  Looking at the code, it
appears
that subclassing WSGIRequestHandler, overriding the
handle
method to dispatch to one of a pool of handler threads
might be an easy way to get reasonalble performance
from this still-simple approach.

At least it *looks* to me like handle method would be
the place to make the transfermation to
thread-per-request.
Comment?

Thanks,
Steve 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Web-SIG mailing list