Revision: 3678
Author: janne.t.harkonen
Date: Mon May 31 00:22:22 2010
Log: Windows requires timeout granularoty for threads and timeout s to work properly
http://code.google.com/p/robotframework/source/detail?r=3678

Modified:
 /trunk/src/robot/running/timeouts.py

=======================================
--- /trunk/src/robot/running/timeouts.py        Sat May 29 10:19:46 2010
+++ /trunk/src/robot/running/timeouts.py        Mon May 31 00:22:22 2010
@@ -58,10 +58,12 @@
         if not self.active:
             return -1
         elapsed = time.time() - self.starttime
-        return self.secs - elapsed
+ # Timeout granularity is 1ms. Without rounding some timeout tests fail + # intermittently on Windows, probably due to threading.Event.wait().
+        return round(self.secs - elapsed, 3)

     def timed_out(self):
-        return self.active and self.time_left() < 0
+        return self.active and self.time_left() <= 0

     def __str__(self):
         return self.string
@@ -93,7 +95,7 @@
             return '%s not active.' % self.type
         if not self.timed_out():
return '%s %s active. %s seconds left.' % (self.type, self.string, - round(self.time_left(), 3))
+                                                       self.time_left())
         if self.message:
             return self.message
         return '%s %s exceeded.' % (self.type, self.string)

Reply via email to