[Python-Dev] Where to put the interrupt module?
Kevin Jacobs
jacobs@penguin.theopalgroup.com
Thu, 12 Jun 2003 16:56:30 -0400 (EDT)
On Thu, 12 Jun 2003, Guido van Rossum wrote:
> > In that past, there have been a few times where it would have been
> > very convenient to terminate/signal another thread by posting an
> > exception to it. Using KeyboardInterrupt to do so is okay, although
> > it seems like something of a kludge.
>
> This gets into the general discussion about whether threads should be
> stoppable.
True -- I am of the opinion that threads should be cooperatively stoppable,
but not preemptively stoppable, if that makes sense. Asynchronous exceptions
are the ideal way of implementing this, since the main interpreter loop is
essentially already instrumented to handle them.
> Also, this mechanism can *only* interrupt the main thread. (That's
> even true of the more generalized version you were thinking of.)
Ah.. that sounds familiar. I knew there was a reason I didn't pursue this
avenue farther last time I poked through that code.
-Kevin
--
--
Kevin Jacobs
The OPAL Group - Enterprise Systems Architect
Voice: (216) 986-0710 x 19 E-mail: jacobs@theopalgroup.com
Fax: (216) 986-0714 WWW: http://www.theopalgroup.com