[Stackless] stacklesssocket.py

Alec Flett alecf at flett.org
Wed Nov 8 23:51:13 CET 2006


I'm trying to retrofit stacklesssocket.py onto an existing synchronous
application and I've run into a few hiccups that I just can't seem to figure
out. I'm on Python 2.5 on Darwin (OS X) using the installer that was
mentioned earlier on the list. A few problems I'm running into:

1) when I call sock.connect(), stackless ends up effectively blocking in
stacklessocket's dispatcher's handle_connect doing
self.connectChannel.send(None)
- I changed this to be
say stackless.tasklet(self.connectChannel.send)(None) which follows the
pattern of the rest of the file. This worked well. This patch in and of
itself was pretty easy, but it baffles me what would be unique about my
application that would make this fail, while other uses of stackless (like
the urllib2 example earlier) would work fine.

2) I had to insert 'gethostname' into the module because I had monkeypatched
stacklesssocket into socket and there was some unrelated code that needed to
call gethostname().

3) I'm trying to just test that everything works in an
effectively-synchronous way before I restructure code to be more parallel,
by just running a single tasklet that does a bunch of effectively
synchronous reads and writes to a single open socket. It is remarkably slow
when using this module and I can't seem to figure out why! The CPU isn't
spinning (at least not hard! it's pretty idle sitting in a select() loop)

The only funny thing I do is mess with the socket's timeouts via
settimeout() before connect() and before the first recv() but it seems like
that should just get passed onto the 'real' socket and not cause any
problems. But in any case, I only make a single connection and then do a
bunch of send/recv's in a typical conversational manner (i.e. for each
message send, a single response is expected, etc)

All told, I'm trying to figure out what sorts of things I should be looking
for in my code, to figure out why:
1) connect() is so problematic here but not in urllib2
2) everything is so slow!

Alec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20061108/41c9ed2f/attachment.htm>
-------------- next part --------------
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless


More information about the Stackless mailing list