[Stackless] Creating a relation between tasklets to forward exceptions

Gabriel Lavoie glavoie at gmail.com
Thu Sep 2 03:37:46 CEST 2010

Hello everyone,
     I'd like to know if there is a simple way to put tasklets in relation.
The idea is to be able to notify some tasklets of the death of another one
so the survivor can take some actions. By looking at stackless.py from the
PyPy project I didn't find anything like this. Maybe there is some way to do
it with channels that I'm not aware of!

With stackless.py, tasklets are implemented on top of coroutines that have
such a behaviour. When a coroutine is started, the starter is considered as
the parent and if the child couroutine throws an exception, it will be
forwarded to the parent. The implementation of tasklets in stackless.py
catch those exceptions and just ignore them. For my Master Degree project I
added an optional relationship between tasklets. First, a .throw(Exception)
method was added to the coroutine class from which the tasklet class
inherits. Then, the code that catches the exception thrown by a tasklet that
ignored it now forwards it to the parent if it's set, wrapped within a
ChildException. To create a relation between tasklets, I added a parameter
to the constructor of the tasklet class. The use of dstackless here is
because I made my own set of classes that override stackless ones. They are
used in the same way.

c = dstackless.channel()

ref_task_sender = dstackless.tasklet(task_sender)(c)

ref_task_receiver = dstackless.tasklet(task_receiver, parent =

If there really isn't any way to create a relation between tasklets to
forward exceptions with Stackless Python, why such a decision was made (if
it was)? I'm just curious and I need to explain this in my thesis.

Thank you very much,


Gabriel Lavoie
glavoie at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20100901/8965b1aa/attachment.html>

More information about the Stackless mailing list