time.monotonic() roll over

Marko Rauhamaa marko at pacujo.net
Thu Dec 4 10:50:55 EST 2014


"ast" <nomail at invalid.com>:

> Does any body know when time.monotonic() rolls over ?

Never, according to the documentation you linked.

Admittedly, the documentation confuses the reader by chatting about some
irrelevant internal Windows details.

Also, the tone of the documentation raises a suspicion that this code
might return a bad value on Windows:

    def fifty_days():
        a = time.monotonic()
        time.sleep(50 * 24 * 3600)
        return time.monotonic() - a

That is, the internal integer wrap is not guarded against between the
calls to time.monotonic(), maybe.


Marko



More information about the Python-list mailing list