I currently have a program that runs at regular intervals. Right now the program runs continuously, checking for new files every 30 minutes:
def filechecker():
#check for new files in a directory and do stuff
while True:
filechecker()
print '{} : Sleeping...press Ctrl+C to stop.'.format(time.ctime())
time.sleep(1800)
However, I'd also like the user to be able to come to the terminal and enter a keystroke to manually call filechecker() instead of either waiting for the program from waking from sleep or having to relaunch the program. Is this possible to do? I tried to look at using threading, but I couldn't really figure out how to wake the computer from sleep (don't have much experience with threading).
I know I could just as easily do :
while True:
filechecker()
raw_input('Press any key to continue')
for full manual control, but I want my to have my cake and eat it too.