mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use the monotonic clock
This commit is contained in:
parent
cd1a36c5fe
commit
0bba6484d1
@ -42,7 +42,7 @@ def rate_limit(name='test', time_between_visits=2, max_wait_seconds=5 * 60, slee
|
||||
lv = float(f.read().decode('utf-8').strip())
|
||||
except Exception:
|
||||
lv = 0
|
||||
delta = time.time() - lv
|
||||
delta = time.monotonic() - lv
|
||||
if delta < time_between_visits:
|
||||
time.sleep(time_between_visits - delta)
|
||||
try:
|
||||
@ -50,7 +50,7 @@ def rate_limit(name='test', time_between_visits=2, max_wait_seconds=5 * 60, slee
|
||||
finally:
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.write(repr(time.time()).encode('utf-8'))
|
||||
f.write(repr(time.monotonic()).encode('utf-8'))
|
||||
|
||||
|
||||
def tostring(elem):
|
||||
|
Loading…
x
Reference in New Issue
Block a user