[Stackless] Concurreny Models In Stackless

Grant Olson olsongt at verizon.net
Tue May 16 02:03:11 CEST 2006


I've been getting interested in lightweight threads lately, so I've started
goofing around with stackless.  It's neat.  Just wanted to bounce a few
ideas off of people who've been using it a little longer to see what they
thought.

When people start talking about concurrency models academically, they tend
to break things down into two major categories: shared-memory concurrency
(traditional threads) and message-passing concurrency (erlang style).

Stackless seems to provide a hybrid of these approaches.  Message passing
controls flow, but you also have a shared memory paradigm.  To emulate a
pure message passing paradigm, I've been writing code that sends messages
back and forth as tuples where the first item is a channel.  So instead of
doing something like:

def tasklet_code(other_object):
	x = other_object.x

I'd send a message like:

other_object.channel.send( (self.channel, "TELL X") )

and follow up with:

self.x = self.channel.receive()[1]


This reasonably simulates pure message-passing, but I honestly don't know
what I'm gaining here, other than being able to say I'm using
message-passing concurrency.  It also seems like the risk of sharing objects
across tasklets it mitigated by the fact that stackless uses a co-operative
threading model.  In this case you don't need to worry about things like
mutexes as much as you would in traditional shared-memory concurrency.

So, for the stackless-literate: How do you handle communication and
interaction between instances of objects such as calling methods and setting
variables? Message passing, the same way you would in normal python, or by
other means?

Any input would be appreciated,

Grant


_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list