If it's 5 seconds before setting the time forward an hour, will time.sleep(10) sleep for 10 seconds, or five seconds? (after five seconds, the time is more than ten seconds from the start).
If it's 5 seconds before setting the time backwards an hour, time.sleep(10) sleep for ten seconds, or for an hour and ten seconds? (it takes an extra hour for the current time to be more than ten seconds from the start time, at least by the clock)
And for completeness, what does sleep do for leap seconds, like we just had?
Are there any times that time.sleep would not be expected to do what is requested?
I'm still on python 2.7.
As the
time.sleep()
document says:time.sleep()
is independent of the time-zone, or your system time. It suspends execution of current thread for the amount of seconds specified while making the call to it.Answer to your question "Are there any times that
time.sleep
would not be expected to do what is requested?" is also available in document:But this is changed in version 3.5, and function sleeps at least secs even if the sleep is interrupted by a signal, except if the signal handler raises an exception (see PEP 475 for the rationale).
Note: The suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system