[Stackless] Stackless module for 2.4

Richard lickspittle at gmail.com
Sat Apr 30 13:31:28 CEST 2005


I was wondering what was involved in getting Stackless to work under
2.4.  Since I assume Christian and Armin are concentrating on PyPy, it
sort of feels like it is unlikely to happen which was what prompted me
to spend some time looking into it out of curiousity.  I looked at
what had been posted around the net relating to Stackless, greenlets
and later versions of Python.  This led to me writing a stackless
equivalent module that should work under 2.4 based on greenlets.

I have not tried it under 2.4.  The greenlet module will not compile
with my Visual Studio 7.0 considering that the Python I have is
compiled with 7.1.  However, I have tried it under 2.3 with Stackless
Python, which it why it is currently named stackliss so as not to
clash with the stackless module.

It only supports the bare minimum that I use on a regular basis.  I
have no idea offhand how to do the following with greenlets, so thet
are present bug unimplemented.

   - the watchdog timeout
   - tasklet.become()
   - taslet.capture()

test.py from the attached file:

import stackliss

def Receiver(channel):
    print "Receiver (before)"
    value = channel.receive()
    print "Received:", value

def Sender(channel):
    print "Sender (before)"
    print "Sender (after)"

def Threebie():
    for i in xrange(3):

if __name__ == "__main__":
    print "***** Sender / Receiver"

    channel = stackliss.channel()
    stackliss.tasklet(Sender)(channel).name = "Sender"
    stackliss.tasklet(Receiver)(channel).name = "Receiver"
    stackliss.tasklet(Threebie)().name = "Threebie"

    while stackliss.runcount:
        t = stackliss.run(0)
        if t:
            print "Timed out tasklet", t

    print "***** Receiver / Sender"

    channel = stackliss.channel()
    stackliss.tasklet(Receiver)(channel).name = "Receiver"
    stackliss.tasklet(Sender)(channel).name = "Sender"

    while stackliss.runcount:
        t = stackliss.run(0)
        if t:
            print "Timed out tasklet", t

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list