Problem breaking out of a thread
Mr. Neutron
nicktsocanos at charter.net
Fri Aug 23 09:00:33 EDT 2002
Hi,
I have a threading.Thread object. inside it has
class DooDad(threading.Thread):
...
def run(self):
while self.bRunning
try:
self.Think()
except KeyboardInterrupt,e:
self.stop()
def stop(self):
self.bRunning = 0
...
later on in my main program I hook Ctrl-C signal
def mysighandler(signum,stack):
raise KeyboardInterrupt,"Yikes!"
signal.signal(signal.SIGQUIT,mysighandler)
Jimmy = DooDad(...)
Jimmy.start()
while 1:
try:
signal.pause()
if(Jimmy.bRunning == 0): break
except KeyboardInterrupt, e:
print e
break
Jimmy.join()
Now when this program is running, the thread reports that it accepted a
interrupt, and that is fine. However, it just freezes up, and never
breaks out of the main loop. I have tried a few ways to get the main
loop to break out but nothing has worked.
at this point I don't need a thread, but I would like to know what
I did wrong and why it just locks up when I hit ctrl-c.
I am working in IDLE, if that makes any difference?
Thanks
More information about the Python-list
mailing list