Ok, another update:<br><br>It turns out I thought the server was blocking but it was just Firefox trying to reuse http sockets for keepalive...so when I reloaded 2 tabs at once, one tab was waiting on the other. Doh! :)<br>
<br>I was actually able to just derive the Stackless HTTP Server class from the WSGIServer class and then it behaves as expected... and it flies! I&#39;m really excited about this solution - I&#39;ve already put together a little mini appserver for what I&#39;m trying to accomplish.
<br><br>Also, there&#39;s a typo in stacklesssocket.py - probably originally from a comment I posted here a while back...<br><br>The code for handle_connect currently says:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stackless.socket(self.connectChannel.send
)(None)<br>and should say:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stackless.tasklet(self.connectChannel.send)(None)<br><br>Now the next problem - how to use stacklessocket to do some kind of asynchat-like behavior (read/write chatty protocol terminated by linefeeds) for a separate socket connection I&#39;m using. stacklessocket seems to constantly block my code on the read if the client calls 
socket.recv() with a bigger buffer than is available immediately.<br><br>Alec<br><br><div><span class="gmail_quote">On 4/6/07, <b class="gmail_sendername">Alec Flett</b> &lt;<a href="mailto:alecf@flett.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
alecf@flett.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So I uncovered the Google Code wiki (<a href="http://code.google.com/p/stacklessexamples/wiki/StacklessExamples" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://code.google.com/p/stacklessexamples/wiki/StacklessExamples
</a>) - it seems like a slightly newer version of the wiki on 
<a href="http://stackless.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">stackless.com</a>. Which should we be using?<br><br>Anyhow, on there I discovered basicWebserver.py which supposedly fires off a tasklet for each connection. I mean the code there looks right, but I&#39;m finding that it&#39;s still blocking on every request - meaning that if one request is running, no more requests can be served.
<br><br>I&#39;m also not sure I see any specific advantage to using stacklesssocket.py here - is that just an extra optimization to get some scheduling done in the socket code? Because it seems like the server (should) be managing most of this pretty well.
<br><br>But I think it will be a good starting point for the StacklessWSGIServer I have in mind. I&#39;ll keep poking at it.<br><span><br>Alec</span><div><span><br><br><div>
<span class="gmail_quote">On 4/6/07, <b class="gmail_sendername">Alec Flett
</b> &lt;<a href="mailto:alecf@flett.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">alecf@flett.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Hey folks -<br>
I&#39;ve scoured the web, the wiki, and anywhere else I can think of. I&#39;m wondering if anyone has written a stackless-based WSGI-compliant http server.. <br><br>I&#39;ve got a bunch of WSGI apps and middleware that I currently run under mod_python with prefork apache. Apache is driving me nuts and I&#39;d like to switch to an asynchronous model. It&#39;s pretty CPU hungry stuff but I think I&#39;ve figured out a good way to break up the work. Stackless seems ideal for this -- just dispatch each http connection to a new tasklet. Plus stackless would allow me to easily share common work between the tasklets.
<br><br>(I looked at Twisted but since WSGI is pretty callstack-oriented, WSGI &amp; Twisted kind of a nasty combination)<br><br>I don&#39;t need anything special from the server itself beyond the WSGI capability because I&#39;m using formencode, selector, and other WSGI-based middleware that does all the work of your classic app server.
<br><br>I started down the road of building on the WSGIServer/WSGIRequestHandler stuff in wsgiref, (which is based on BaseHTTPServer) but as it started to get complicated I thought, surely someone has dealt with this stuff before?
<br><br>As an aside, this stuff will be eventually running on multi-core machines. Two cores today, and I&#39;m sure more tomorrow. One thought I had was to run one long-running stackless python for each core, and let lighttpd do the work. In that case, maybe what I really need is a fastcgi-wsgi gateway that&#39;s stackless friendly. Has anyone explored that avenue?
<br><br>But hey, if nobody else has done this stuff, I&#39;ll be happy to share my work....<br><span><br>Alec
</span></blockquote></div><br>
</span></div></blockquote></div><br>