[Stackless] Implementing CSP

Tom Locke tom at livelogix.com
Thu Jan 8 08:54:03 CET 2004

> > p.s. My Stackless install crashes whenever a tasklet raises an
> > expcetion. I haven't looked into it further yet - whether catching
> > exception will prevent the crash. Is this a known problem? Something
> > doing wrong?
> Hmm...
> No, can't reproduce this error.

Turns out it was related to my par function, here's my efforts to
isolate the bug:

1. scheduling via channel.receive()

>>> stackless.tasklet(lambda: 1/0)()
<stackless.tasklet object at 0x008F9698>
>>> stackless.channel().receive()

Whereas this is fine:

>>> stackless.tasklet(lambda: 1/0)()
<stackless.tasklet object at 0x00862500>
>>> stackless.schedule()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 1, in <lambda>
ZeroDivisionError: integer division or modulo by zero
>>> stackless.channel().receive()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: the last runnable tasklet cannot be blocked.

Seems to be something to do with the exception causing another stackless
exception (e.g. "can't block the last tasklet")???

I have tried to fix my par function like this:
def par(*funcs):
    taskEnd = stackless.channel()
    def signalEnd(f):

    for f in funcs:

    count = len(funcs)
    while count > 0:
        count -= 1
But it still crashes if one of the funcs raises an exception.

I have found one way to fix it - create the taskEnd channel outside the
function (as a global). Then it works fine, but of course the semantics
are messed up if there is more than one par in a program.

I have tried *lots* of different workarounds, but haven't got there yet.


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list