Is there a way I can use threads to quit the main python process?<br>In brief, I have a python script that starts when my computer starts. It chooses a random wallpaper background out of a specified path, and sets it as the desktop wallpaper. It also hooks some windows hot keys so I can cycle through all the wallpapers, or choose another one, or quit it, by using F8, F7 and F6 respectively.<br>
However, I would quite like the script to self-terminate if no user input is received after X seconds. At first this seemed simple - Create a separate thread that used time.sleep() to sleep for X seconds, then run a callback. The callback would check a simple Boolean (Set to True if a hot key is pressed, set to False at start of the script), and if the Boolean was False, it would simply run exit(), and this would close the window.<br>
<br>However, it is not that simple. The callback and the thread work fine, but the exit() seems to close the THREAD, not the main process. I have tried sys.exit(), and some other forms I found on the Internet (Raising exceptions and setting the thread to a daemon), but none seemed to close the actual interpreter. I tried using the .join() function, but this called an exception that told me the thread could not be joined.<br>
<br>Here is my threaded_test.py code: <a href="http://pastebin.com/f6060d15a">http://pastebin.com/f6060d15a</a><br><br>Thanks for reading,<br>~Tom<br><br><br>