bug report: [ #447945 ] time.time() is not non-decreasing

zooko at zooko.com zooko at zooko.com
Sat Aug 4 11:09:10 EDT 2001


[[[As an aside on the topic of bug-tracking systems: 

   I submitted this on sourceforge, and discovered that it escapes HTML tags so
   that they just show up in your text.  So this is the worst of both worlds:
   your formatting options are even more limited than simple ASCII e-mail bug
   reports would be, and you can't use your familiar e-mail UI, you have to use
   this slow, unstable, inconvenient, ugly HTML UI.  I suppose the one
   advantage of an HTML-based bug tracking system like that is that people who
   can't/won't submit e-mail bug reports might submit HTML bug reports, but 
   I have to suggest that those are often the least valuable bug reports...]]]


After spending many hours tracking down weird race conditions in Mojo
Nation[1], I've finally realized that the problem is that we assumed that
`time.time()' would return non-decreasing answers. In fact, successive calls to
`time.time()' can return a *smaller* number than previous calls, as
demonstrated by this test (Python 2.0 on debian woody):

import time 

x = 0 
while 1: 
    ox = x 
    x = time.time() 
    if x < ox: 
        print "this is WRONG: ox: %s, x: %s\n" % (ox, x,) 
    else: 
        print ".", 

In order to get the race conditions out of Mojo Nation, I'm writing a
`non_decreasing_time()', which does what we thought `time()' would do. In fact,
I might just make it `increasing_time()'.  In any case, the `time.time()' in
the standard library should either be fixed to be non-decreasing (my
preference), or the documentation should be updated to warn about the
surprise.

Regards,

Zooko

[1] http://mojonation.net/





More information about the Python-list mailing list