[Python-bugs-list] [ python-Bugs-447945 ] time.time() is not non-decreasing
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 04 Aug 2001 08:02:55 -0700
Bugs item #447945, was opened at 2001-08-04 08:02
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=447945&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Zooko Ozoko (zooko)
Assigned to: Nobody/Anonymous (nobody)
Summary: time.time() is not non-decreasing
Initial Comment:
<p>After spending many hours tracking down weird race
conditions in <a href="http://mojonation.net/">Mojo
Nation</a>, I've finally realized that the problem is
that we assumed that <cite>time.time()</cite> would
return non-decreasing answers. In fact, successive
calls to <cite>time.time()</cite> can return a
<em>smaller</em> number than previous calls, as
demonstrated by this test (Python 2.0 on debian
woody):</p>
<pre>
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 ".",
</pre>
<p>In order to get the race conditions out of Mojo
Nation, I'm writing a
<cite>non_decreasing_time()</cite>, which does what we
thought <cite>time()</cite> would do. In fact, I might
just make it <cite>increasing_time()</cite>. In any
case, the <cite>time.time()</cite> in the standard
library should either be fixed (my preference) to be
non-decreasing, or the documentation should be updated
to warn about the surprise.</p>
<p>Regards,</p>
<p><b><i>Zooko</i></b></p>
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=447945&group_id=5470