time.monotonic() roll over

Marko Rauhamaa marko at pacujo.net
Thu Dec 4 13:09:49 EST 2014


Chris Angelico <rosuav at gmail.com>:

> It's not a Python issue. Python can't do anything more than ask the
> system, and if the system's value rolls over several times a year,
> Python can't magically cure that. The information has already been
> lost.

Sure it could by having an invisible background thread occasionally call
time.monotonic(). It could even be done on the side without a thread.

Anyway, the idea of a clock is complicated:

 * the program could be stopped by a STOP signal

 * the program could be suspended from power management

 * the program could be resurrected from a virtual machine snapshot

 * the program could be migrated from a different physical machine

So, if I call

   time.sleep(86400)

and the program is suspended for 24 hours, should time.sleep() return
right after it is resumed or after another 24 hours?


Marko



More information about the Python-list mailing list