[Python-ideas] Thread exceptions and interruption

Adam Olsen rhamph at gmail.com
Wed Sep 19 07:25:09 CEST 2007

On 9/18/07, Alex Holkner <aholkner at cs.rmit.edu.au> wrote:
> Adam Olsen wrote:
> > Here I use a with-statement[2] to create a branch point.  The branch
> > point collects any exceptions from its children and interrupts the
> > children when the first exception occurs.  Interruption is done
> > somewhat similarly to posix cancellation; participating functions
> > react to it.  However, I raise an Interrupted exception, which can
> > lead to much more graceful cleanup than posix cancellation. ;)
> It sounds like you're proposing that a thread can be interrupted at any
> time.  The Java developers realised long ago that this is completely
> unworkable and deprecated their implementation:
> http://java.sun.com/j2se/1.3/docs/guide/misc/threadPrimitiveDeprecation.html
> Please disregard if I misunderstood your approach :-)

You misunderstood. :)  The key word was *participating* functions.
Normally this only includes things like file or socket reading.  A
CPU-bound busy loop may never get interrupted.

Adam Olsen, aka Rhamphoryncus

More information about the Python-ideas mailing list