Use time.monotonic instead of time.time where appropriate (#31780)

This commit is contained in:
Ville Skyttä authored and GitHub committed 2020-02-13 22:57:07 +01:00
1 parent fbbb29a6ec
commit 3018e8ff47
8 files changed
+21 -23

No files matched your search

+3 -3
View File
@@ -90,14 +90,14 @@ class MaxCubeHandle:
self.cube = cube
self.scan_interval = scan_interval
self.mutex = Lock()
self._updatets = time.time()
self._updatets = time.monotonic()
def update(self):
"""Pull the latest data from the MAX! Cube."""
# Acquire mutex to prevent simultaneous update from multiple threads
with self.mutex:
# Only update every update_interval
if (time.time() - self._updatets) >= self.scan_interval:
if (time.monotonic() - self._updatets) >= self.scan_interval:
_LOGGER.debug("Updating")
try:
@@ -106,6 +106,6 @@ class MaxCubeHandle:
_LOGGER.error("Max!Cube connection failed")
return False
self._updatets = time.time()
self._updatets = time.monotonic()
else:
_LOGGER.debug("Skipping update")