question about ctrl-d and atexit with threads
Darren Dale
dsdale24 at gmail.com
Thu Mar 5 10:19:16 EST 2009
Actually, this problem can also be seen by running this code as a
script, it hangs up if the sys.exit lines are commented, and exits
normally if uncommented.
import atexit
import threading
import time
class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
self.stopEvent = threading.Event()
def run(self):
while not self.stopEvent.isSet():
time.sleep(0.1)
def stop(self):
self.stopEvent.set()
self.join()
my_thread = MyThread()
def stop_execution():
my_thread.stop()
atexit.register(stop_execution)
my_thread.start()
#import sys
#sys.exit()
More information about the Python-list
mailing list