[Stackless] Stackless / Networking

Andrew Francis andrewfr_ice at yahoo.com
Tue Feb 20 19:52:47 CET 2007

Message: 1
Date: Tue, 20 Feb 2007 00:46:46 -0600
From: Marcus <shutterbug at dwx.com>
Subject: [Stackless] Stackless / Networking /
Distributed Server
To: stackless at stackless.com
Message-ID: <45DA9956.9080802 at dwx.com>
Content-Type: text/plain; format=flowed;

Hi Marcus:

>Is stackless the right tool for the job? I know Eve
>Online has used it (and that's how I found Stackless
>in the first place), but after searching it appears
>that Stackless doesn't work well with networking 
>right now (monkeypatching excepted); I've seen quite
a >bit of discussion about Stackless with networking
and >blocking issues, but I haven't been 
>able to find what peoples' solutions were.

>It appears that Twisted would be a good library to
>use, but it also doesn't play well with Stackless.
>I've seen posts by Andrew on this topic; has anyone
>found a production-quality solution to integrating 

Marcus, I have been experimenting with Stackless and
Twisted for a while. After a few false starts, I think
I have a solution that works for most cases I

As for whether to use Stackless Python or CPython. I
guess it depends on your problem.

I use Stackless for two reasons: 1) The pickling of
execution state greatless simplifies the design of my
application. 2) Stackless has an elegant concurrency
model. The light weight nature of tasklets is a bonus.
Regardless, I would argue that I were doing
complicated networking with Python, I would use

As we speak, I am writing a tutorial on how I use
Twisted with Stackless. I will try to get this out by
the weekend. In my case, I have additional
difficulties because my application must be able to
act both as a server and a client simultaneously. 

The essence of my proposed solution is to execute
Twisted and Stackless in separate OS threads and have
them communicate through a queue. In turn, one has a
"dispatcher" tasklet that communicates between
tasklets that make I/O requests and Twisted. The
Stackless thread is started using Twisted's
callInThread() function. Stackless accesses Twisted
calls using callFromThread(). Yes there is overhead to
this solution. However I can now use a tasklet to
process network I/O instead of an OS thread.


Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list