On Thu, Dec 4, 2014 at 3:44 PM, Marko Rauhamaa <[email protected]> wrote: > > Ian Kelly <[email protected]>: > > > It's not clear to me whether those cases are relevant to the rollover > > concern anyway. I wouldn't be shocked if the GetTickCount() function > > simply stopped increasing while the system is suspended, since after > > all it's not "ticking" during that time. > > So, what's the semantics of time.sleep(), select.select() et al wrt > process or machine suspension?
Rather than continue to speculate, I just tested this. I ran the following script in a Windows 7 VM and paused the VM for part of the duration of the sleep call. I unpaused well before the sleep call would normally have ended. >>> import time >>> def test(): ... t1 = time.time() ... m1 = time.monotonic() ... time.sleep(60) ... t2 = time.time() ... m2 = time.monotonic() ... return t2 - t1, m2 - m1 ... >>> test() (84.92642459869386, 60.002399999999994) As you can see, the sleep call and the monotonic time elapsed both appear to exclude the period when the VM was paused. Then I tried the same with a MacBook and putting the system to sleep instead of pausing a VM: >>> test() (59.889225006103516, 60.00102640298428) Reducing the sleep time to 10 seconds and suspending the process with Ctrl-Z produces a similar result on the MacBook: (10.000508069992065, 10.000266332994215) But the story is different in Linux. Here's what I got with the same Ctrl-Z test: (16.000478506088257, 16.000478034024127) I think the relative roundness of those numbers is just coincidence. I tried a second time and got: (12.613622903823853, 12.613622067990946) So it seems that it can go either way depending on the OS and perhaps the mechanism of suspension.
-- https://mail.python.org/mailman/listinfo/python-list
