Change in vdsm[master]: stomp: use monotonic timer instead of clock

smizrahi at redhat.com smizrahi at redhat.com
Mon Jan 19 13:45:39 UTC 2015


Saggi Mizrahi has uploaded a new change for review.

Change subject: stomp: use monotonic timer instead of clock
......................................................................

stomp: use monotonic timer instead of clock

Change-Id: I58fa9009c72422f28065282cdb3b5d20f010ec80
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M lib/yajsonrpc/stomp.py
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/37056/1

diff --git a/lib/yajsonrpc/stomp.py b/lib/yajsonrpc/stomp.py
index 884bff6..3fb519c 100644
--- a/lib/yajsonrpc/stomp.py
+++ b/lib/yajsonrpc/stomp.py
@@ -19,7 +19,7 @@
 from threading import Timer, Event
 from uuid import uuid4
 from collections import deque
-import time
+import os
 
 from betterAsyncore import Dispatcher
 import asyncore
@@ -35,6 +35,9 @@
 }
 
 _ESCAPE_CHARS = (('\\\\', '\\'), ('\\r', '\r'), ('\\n', '\n'), ('\\c', ':'))
+
+
+elapsed_time = lambda: os.times()[4]
 
 
 class Command:
@@ -333,7 +336,7 @@
 
     def recv(self):
         timeout = self._timeout
-        s = time.time()
+        s = elapsed_time()
         duration = 0
         while timeout is None or duration < timeout:
             try:
@@ -341,7 +344,7 @@
             except IndexError:
                 td = timeout - duration if timeout is not None else None
                 self.process(td)
-                duration = time.time() - s
+                duration = elapsed_time() - s
 
         return None
 
@@ -361,12 +364,12 @@
         disp = self._disp
         timeout = self._timeout
         duration = 0
-        s = time.time()
+        s = elapsed_time()
         while ((timeout is None or duration < timeout) and
                (disp.writable() or not self._connected.isSet())):
                 td = timeout - duration if timeout is not None else None
                 self.process(td)
-                duration = time.time() - s
+                duration = elapsed_time() - s
 
     def gettimout(self):
         return self._timeout
@@ -471,7 +474,7 @@
         return True
 
     def _milis(self):
-        return int(round(time.time() * 1000))
+        return int(round(elapsed_time() * 1000))
 
 
 class AsyncClient(object):


-- 
To view, visit http://gerrit.ovirt.org/37056
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I58fa9009c72422f28065282cdb3b5d20f010ec80
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list