I'm trying to have my script trigger a user input when the user pressed the return key. The main program will then check the txUpdated flag and use this input.
I have a thread running in python that simply 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 I don't know how to end this thread at any point without receiving a user input. Even if my main program sets the endFlag the thread wont end until the user inputs one more input.
Does anyone have any suggestions on how to accomplish this?