I wanted to write a PyQt app that would spawn its window in a separate thread so I could mess with its data structures in an interactive shell while it's running. Unfortunately, an attempt to do exit() inside the shell does not kill the application, probably because the Qt thread is still running. How do I force the Python shell to die once I pressed CTR+D or typed exit() or typed exit in the console? Here is the testcase:
#!/usr/bin/python -i
from PyQt4 import QtGui
class MainWindow(QtGui.QMainWindow):
pass
def main():
import sys
app = QtGui.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
import threading
threading.Thread(None, main).start()