Use octoprint.util.monotonic_time instead of monotonic

This commit is contained in:
Gina Häußge committed 2018-03-22 11:41:31 +01:00
1 parent f981cca47e
commit 70254e910c
2 files changed
+8 -7

No files matched your search

@@ -5,9 +5,10 @@ __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agp
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
import monotonic
import time
from octoprint.util import monotonic_time
def can_perform_update(target, check, online=True):
return True
@@ -15,9 +16,9 @@ def can_perform_update(target, check, online=True):
def perform_update(target, check, target_version, log_cb=None, online=True):
duration = check.get("duration", 30)
now = monotonic.monotonic()
now = monotonic_time()
end = now + duration
while now < end:
log_cb(["{}s left...".format(end - now)], prefix=">", stream="output")
time.sleep(5)
now = monotonic.monotonic()
now = monotonic_time()
+4 -4
View File
@@ -28,7 +28,7 @@ try:
except AttributeError:
# pyserial < 3.2: add backported Timeout abstraction, slightly modified since we have monotonic available
import monotonic
from octoprint.util import monotonic_time
class _Timeout(object):
def __init__(self, duration):
"""Initialize a timeout with given duration"""
@@ -36,7 +36,7 @@ except AttributeError:
self.is_non_blocking = (duration == 0)
self.duration = duration
if duration is not None:
self.target_time = monotonic.monotonic() + duration
self.target_time = monotonic_time() + duration
else:
self.target_time = None
@@ -51,10 +51,10 @@ except AttributeError:
elif self.is_infinite:
return None
else:
delta = self.target_time - monotonic.monotonic()
delta = self.target_time - monotonic_time()
if delta > self.duration:
# clock jumped, recalculate
self.target_time = monotonic.monotonic() + self.duration
self.target_time = monotonic_time() + self.duration
return self.duration
else:
return max(0, delta)