I'm currently having trouble when trying to close my application. As of now, my application currently spawns and thread that runs in a while loop (while True loop), while my main thread initializes and runs the UI in PyQT.
def main():
group_size = 8
buffer_size = 4
app = QtGui.QApplication(sys.argv)
dgui = DirectGui(group_size, buffer_size)
engine = KCluster_Engine(group_size, buffer_size)
dgui.set_engine_ref(engine)
engine.assign_interface(dgui)
thread = Thread(target = engine.start)
thread.start()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
When I close out of my main window of my application in PyQT, the command that spawned the python script in the shell cannot be stopped, even with a ctrl-c.
What is the best way to deal with this behavior? When I close my application, I also want the spawned thread to stop, join and quit this process. How do I do this?