In the WHILE loop, I wanna run two function, one is base function, which will run everytime, the other is user_input function, when user input 'disarm', program can run user_input function. This two function need in WHILE loop so can run all the time.
How could I do to write a function to accomplish this?
Because its realtime so I cant add time.sleep in threading.
Thanks.
import threading
class BackInput(threading.Thread):
def __init__(self):
super(BackInput, self).__init__()
def run(self):
self.input = raw_input()
while True:
threading1 = BackInput()
threading1.start()
threading1.join()
if threading1.input == 'disarm':
print 'Disarm'
break
print 'Arm'
In this code, the program should print Arm every second, when I typed disarm, it can print Disarm and break it.