I have two programs program1.py is like commandline interface which takes command from user program2.py has the program which runs the relevant program as per the command.
Program 1 has also has an quit_program() module In our simple universe.. lets say I have just one command and just one program So lets say...
program1.py
def main():
while True:
try:
command = raw_input('> ')
if command == "quit" :
return
if command == '':
continue
except KeyboardInterrupt:
exit()
parseCommand(command)
And then I have:
if commmand == "hi":
say_hi()
Now program2 has
def say_hi():
#do something..
Now there can be two cases... Either say_hi() completes in which case no issue... But what i want is that if user enters a command (say: end) then this say_hi() is terminated in between..
But my current implementation is very sequential.. I mean I dont get to type anything on my terminal untill the execution is completed.. Somethng tells me that the say_hi() should be running on another thread?
I am not able to think straight about this. Any suggestions? Thanks