Use time.monotonic instead of time.time where appropriate (#31780)
This commit is contained in:
1 parent
fbbb29a6ec
commit
3018e8ff47
8 files changed
+21
-23
No files matched your search
@@ -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")
|
||||
Reference in new issue
Block a user