[Stackless] Stackless / Networking / Distributed Server

Richard Tew richard.m.tew at gmail.com
Tue Feb 20 11:29:49 CET 2007

On 2/20/07, Lloyd Weehuizen <lloyd at fusion.net.nz> wrote:
> On 20/02/2007, at 7:46 PM, Marcus wrote:
> > 1. Receive client request (e.g. Login)
> > 2. Server "frontend" begins handling message
> > 3. During handling, server frontend would need to notify and
> > communicate
> > with other server nodes; procedural-style programming would be most
> > straightforward for that type of procedure
> > 4. Send response to client
> >
> > 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.
> >
> I think stackless would be a great tool for this job. As you say
> writing in a procedural manor would greatly help the development and
> stackless excels at doing just that.
> You're correct that there's no direct route to take as stackless
> doesn't natively solve your blocking issues however with a day or
> twos work developing a framework you'll be up and running with no
> problems at all.

I agree completely with this.  If you want things to work in a
synchronous manner, you are going to have to do the wrapping
yourself whether it is networking or not.

To look at Stackless as not working well with networking is to
expect too much from it :)  For it to work well with networking it
would need to push a solution on you, rather than leaving it open
to the use to choose the solution that suits them.  And Stackless
is just a microthreading solution.

For me the stacklesssocket module and monkeypatching is the
solution I personally prefer.  But that only gets some of the way there
if you use other modules which use the socket module.  If I for
instance use the HTTPServer from the standard library, I still need
to wrap its connection accepting so that requests are started in
their own tasklets.

> I don't have much experience with Twisted myself, so can't comment
> there. The way I got round the issue was to write a simple RPC
> framework.
> Whenever I do an call to a remote server, I use a special Proxy
> class, that wraps the call, serialises all the parameters into a data
> stream and sends the data to the socket, at this point I block on a
> stackless channel and the calling tasklet is suspended. Other
> tasklets are then free to run and one of the these tasklets processes
> all incoming data, when it gets a response for a rpc request
> ( they're all tagged with unique ids ) it simply looks the request up
> in a table and wakes the correct tasklet, which deserialises the
> remote functions return value and returns it like a normal function.

Here is a simple example I wrote along these lines:


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list