Interrupting a thread...

David Allen s2mdalle at titan.vcu.edu
Sat Dec 16 11:28:53 EST 2000


I'm writing a program which does some networking,
and I have a thread that is devoted to grabbing 
things off of the network so that the program won't
hang while it is reading data.

The problem is, I also occasionally need to interrupt
this data fetching operation, so I need a way to
either raise an exception in the other thread, or
otherwise signal to it to stop what it's doing.
Since the download thread calls other functions
that are not sensitive to the data in the original
object, I can't check to see if some value has 
changed each time I'm reading in a loop.

Ideally, I'd like thread 1 to raise an exception
that would be propagated in thread 2, not thread 1.
Is this possible?  What other techniques might work?

Any help would be appreciated.
-- 
David Allen
http://opop.nols.com/
----------------------------------------
He played the king as if afraid someone else would play the ace. 
- John Mason Brown, drama critic



More information about the Python-list mailing list