diff --git a/lomond/session.py b/lomond/session.py index 0df899b..9d8906a 100644 --- a/lomond/session.py +++ b/lomond/session.py @@ -13,10 +13,11 @@ import socket import ssl import threading -import time from six.moves.urllib.parse import urlparse +from monotonic import monotonic as monotonic_time + from .frame import Frame from . import errors from . import events @@ -60,7 +61,7 @@ def session_time(self): return ( 0.0 if self._start_time is None else - time.time() - self._start_time + monotonic_time() - self._start_time ) def close(self): @@ -332,7 +333,7 @@ def _on_ready(self): """Called when a ready event is received.""" self._last_pong = 0.0 self._next_ping = 0.0 - self._start_time = time.time() + self._start_time = monotonic_time() def _on_event(self, event, auto_pong=True): """Handle logic in response to an event.""" diff --git a/setup.py b/setup.py index 1282454..b5d6e4b 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ setup_requires=['pytest-runner'], tests_require=['pytest'], install_requires=[ + 'monotonic>=1.5', 'six>=1.10.0', ], zip_safe=True