I have a python script that is downloading data on a remote computer. I want to prevent the computer from going to sleep as long as the data download is in progress. However if the program finishes/hangs/crashes, I want the computer to go to sleep.
I do not want to disable hibernation settings on my computer. I've looked around at programs like insomnia & command line shortcuts ( How can I put the computer to sleep from Command Prompt/Run menu? ) but they aren't perfect for the job. Any way I can put a try:except:finally block around my python code and call some function to put the computer to sleep ?
Found this answer useful : What is the command to use to put your computer to sleep (not hibernate)? . I created a little one line
sleep app that I can call from my python
finally block using os.system call.