From 10457e876ad6db9c66973c925b7e65f2a16ffbca Mon Sep 17 00:00:00 2001 From: Israel Nir Date: Thu, 10 Jan 2013 15:51:37 +0200 Subject: [PATCH] adding read timestamp to enable better resolution of when certain reads were performed (timestamp is updated when the first byte is available on the network) --- netlib/tcp.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netlib/tcp.py b/netlib/tcp.py index 7656e3989..76fb7ca04 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -44,6 +44,7 @@ class _FileLike: def __init__(self, o): self.o = o self._log = None + self.timestamp = None def set_descriptor(self, o): self.o = o @@ -80,6 +81,8 @@ class _FileLike: if self.is_logging(): self._log.append(v) + def reset_timestamp(self): + self.timestamp = None class Writer(_FileLike): def flush(self): @@ -131,6 +134,7 @@ class Reader(_FileLike): raise NetLibDisconnect except SSL.SysCallError, v: raise NetLibDisconnect + self.timestamp = self.timestamp or time.time() if not data: break result += data