I am trying to have my script run user input when the user presses the return key. Then the main program checks the txUpdated flag and uses this input.
I have a thread running in python that just waits for user input:
class InputThread(threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): global screenLock global txUpdated global txMessage global endFlag lock = threading.Lock() print "Starting " + self.name while not endFlag: txMessage = raw_input() if (txMessage == ""): screenLock = 1 txMessage = raw_input("Enter Tx String: ") screenLock = 0 with lock: txUpdated = 1 print "Exiting " + self.name
The problem is that I do not know how to end this thread at any time without receiving user input. Even if my main program sets endFlag, the stream will end until the user enters another input.
Does anyone have any suggestions on how to do this?
source share