[Stackless] Exception passing patch

Peter Ingebretson pingebre at yahoo.com
Wed Dec 2 21:01:23 CET 2009


> > I too find it odd that one cannot send an exception
> > instance over like this, although I've never came across a
> > specific use case.
>
> Well, I missed the ability to do this when it was removed,
> but these days I am unable to think of any situation where
> it would be cleaner than sending the type and arguments to
> be raised.

In my case, I have an ownership relationship between tasklets, and would like to be able to propagate exceptions intact from a worker tasklet to its owner.

In other words, tasklet A might spawn several tasklets B_i as workers.  If tasklet A is killed, each B_i should also be killed.  Likewise, if one of the workers exits due to an exception, the exception should propagate back to A.  Tasklet A can then decide how to proceed, e.g, spawn another worker to replace the one that failed, or abort itself.

This is all possible using stock stackless without my patch.  Unfortunately, if the ownership depth exceeds one level it can be very difficult to debug where an exception originated.  Being able to associate traceback information with a passed exception addresses this problem.

I considered extending tasklet.raise_exception and channel.send_exception to take an optional traceback keyword argument, but after reading http://www.python.org/dev/peps/pep-3109/ it seemed that supporting passing exception instances was more in line with the direction that Python 3.x was heading.

Thanks,
Peter



      




More information about the Stackless mailing list