Again, sleep suspends your thread - it uses next to zero processing power. To demonstrate, create a script like this (I first attempted this in an interactive Python 3.5 shell, but sub-processes can't find the party_later function for some reason):
The accuracy of the time.sleep function depends on your underlying OS's sleep accuracy. For non-real-time OSs like a stock Windows, the smallest interval you can sleep for is about 10-13ms. I have seen accurate sleeps within several milliseconds of that time when above the minimum 10-13ms. Update: Like mentioned in the docs cited below, it's common to do the sleep in a loop that will make sure ...
time.sleep(NUM) How can I make a thread sleep until 2AM? Do I have to do math to determine the number of seconds until 2AM? Or is there some library function? ( Yes, I know about cron and equivalent systems in Windows, but I want to sleep my thread in python proper and not rely on external stimulus or process signals.)
While 1: time.sleep(60) In the above code when the control enters time.sleep function an entire 60 seconds needs to elapsed for python to handled the CTRL C Is there any elegant way to do it. such that I can interrupt even when the control is in time.sleep function edit I was testing it on a legacy implementation which uses python 2.2 on windows 2000 which caused all the trouble . If I had ...
I'd like to write a short python script that puts my computer to sleep. I'Ve already searched the API but the only result on suspend has to do with delayed execution. What function does the trick ?