How to force a thread to stop

sjdevnull at yahoo.com sjdevnull at yahoo.com
Thu Jul 27 13:19:08 EDT 2006


Carl J. Van Arsdall wrote:
> Well, I guess I'm thinking of an event driven mechanism, kinda like
> setting up signal handlers.  I don't necessarily know how it works under
> the hood, but I don't poll for a signal.  I setup a handler, when the
> signal comes, if it comes, the handler gets thrown into action.  That's
> what I'd be interesting in doing with threads.

Note that you see many of the same problems with signal handlers
(including only being able to call reentrant functions from them).

Most advanced Unix programming books say you should treat signal
handlers in a manner similar to what people are advocating for remote
thread stoppage in this thread: unless you're doing something trivial,
your signal handler should just set a global variable.  Then your
process can check that variable in the main loop and take more complex
action if it's set.




More information about the Python-list mailing list