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() -- http://mail.python.org/mailman/listinfo/python-list