I am running pythoncom.PumpMessages() inside a thread. This line will cause the thread to stop and wait for events. I have been unable to send WM_QUIT, which needs to be sent to stop this line from waiting. Now I am considering to use os._exit(0) to stop the whole program. Using this method also seems to make my code much more elegant, as I do not need various threads to notify eachother and so on. I just create a method, which looks something like this and call it from anywhere:
def os_exit():
....saveDataAndCleanUp()
....os._exit(0)
I know that this is a very rough way to do it, and I might loose data, and it stops the process
without calling cleanup handlers, flushing stdio buffers, etc. (Python docs)
I will sort out ways to ensure that I will not loose data (this is easy in this small program). My worry now is that I have both keyboard and mouse hooks using pyHook. Could it cause problems that they are not unhooked before the process stops. My program is only running on Windows XP+. Is there anything else my application could do, which would cause Windows to become unstabile, slow or similar, or will Windows take care of the cleanup for me? My application is more or less a standard GUI application, which does not writ开发者_StackOverflowe to the registry or modify Windows in any way.
精彩评论