python exit a blocking thread?
问题 In my code I loop though raw_input() to see if the user has requested to quit. My app can quit before the user quits, but my problem is the app is still alive until I enter a key to return from the blocking function raw_input() . Can I do to force raw_input() to return by maybe sending it a fake input? Could I terminate the thread that it's on? (the only data it has is a single variable called wantQuit ). 回答1: You can use this time out function that wraps your function. Here's the recipe from