Close multi threaded application with KeyboardInterrupt
问题 I have an app with two threads. One is a pygame thread which runs a simple game, the other thread is a listening server which accepts messages which are used to control the game. Here is the stripped down pseudo code: class ServerThread(threading.Thread): def run(self): class SingleTCPHandler(SocketServer.BaseRequestHandler): try: while(1): ... #Receive messages from socket. Add them to pygame event queue ... except KeyboardInterrupt: sys.exit(0) ... ... class PygameThread(threading.Thread):