Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a monotonic clock for WebsocketSession's session_time #64

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lomond/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -321,7 +322,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."""
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
setup_requires=['pytest-runner'],
tests_require=['pytest'],
install_requires=[
'monotonic>=1.5',
'six>=1.10.0',
],
zip_safe=True
Expand Down