I need to print a message every x seconds, at the same time, I need to listen to the user's input. If 'q' is pressed, it should kill the program.
For example
some message
.
. # after specified interval
.
some message
q # program should end
The current problem I face now is that raw_input
is blocking which stops the my function from repeating the message. How do I get input reading and my function to run in parallel?
EDIT: It turns out that raw_input
was not blocking. I misunderstood how multi-threading works. I'll leave this here in case any one stumbles upon it.