'In python, how can I make a program sleep based on the real-world clock instead of the CPU clock
TL;DR; How to make a program sleep based on the real-world clock instead of the CPU clock without using while ...: pass
In python, I can make a program sleep for a certain amount of time using the time.sleep() function. However, this function follows the CPU clock which means if I make the program sleep for one hour and in the middle of that my PC goes to sleep for 30 minutes, the program will actually sleep for one and a half hours.
My primary intention in using sleep is to overcome GitHub API's rate limit. Therefore, when I make the program sleep for one hour, I want it to sleep for exactly one hour (plus the scheduling overhead).
One possible solution could be using while ...: pass until a certain time. However, this would keep a processor busy the whole time and that is something I don't want.
Is there any way to make a python program sleep following the real-world clock?
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Camp |
