Reputation: 1770
I have a Python application that regularly dies when the computer goes to sleep. It works well on Mac, Windows and Linux on it's own, but the sleep problem is irritating.
Is there a function/library that would let me deal with sleep mode in a platform independant way?
Something like
if(OSSLEEP){
#Reduced Functionality
}
I would be happy if the program simply didn't crash, as I realize it is probable that no functionality is possible during sleep.
I researched the question: How can I check to see if system is in standby mode?
It seems there is a Win32 API function which does this: By this reasoning there might be a Python library that does the same thing. Notification when Windows enters in sleep mode
This seems to say it's not possible and a bad idea: Multithreaded python urllib2-based downloader drives the computer to Standby/Sleep
I would love to know if this is do-able even if it's not advisable.
Upvotes: 2
Views: 981
Reputation: 288280
During sleep mode, no program is running. That's kind of the point, since modern CPUs use significantly virtually no power when not doing anything.
Additionally, your problem is not exclusive to the sleep mode. It will also occur if the connection drops out, or if your process doesn't get notified during hibernation, or if your network interface is restarted, or … .
So the correct way to solve your problem is: Ask a new question with your code and the error you're getting.
Upvotes: 1