mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
using monotonic time
This commit is contained in:
parent
65c6abee24
commit
58f60bb49f
@ -80,9 +80,9 @@ class Snapshoter: # pylint: disable=too-many-instance-attributes
|
||||
last_snapshot_ts = 0.0
|
||||
while True:
|
||||
live = is_live()
|
||||
if last_snapshot_ts + (self.__live_interval if live else self.__idle_interval) < time.time():
|
||||
if last_snapshot_ts + (self.__live_interval if live else self.__idle_interval) < time.monotonic():
|
||||
await self.__take_snapshot(live, notifier)
|
||||
last_snapshot_ts = time.time()
|
||||
last_snapshot_ts = time.monotonic()
|
||||
await asyncio.sleep(min(self.__idle_interval, self.__live_interval))
|
||||
else:
|
||||
await aiotools.wait_infinite()
|
||||
|
||||
@ -66,9 +66,9 @@ class _SpiPhyConnection(BasePhyConnection):
|
||||
assert len(request) == 8
|
||||
assert request[0] == 0x33
|
||||
|
||||
deadline_ts = time.time() + self.__read_timeout
|
||||
deadline_ts = time.monotonic() + self.__read_timeout
|
||||
dummy = b"\x00" * 8
|
||||
while time.time() < deadline_ts:
|
||||
while time.monotonic() < deadline_ts:
|
||||
if bytes(self.__xfer(dummy)) == dummy:
|
||||
break
|
||||
else:
|
||||
@ -78,9 +78,9 @@ class _SpiPhyConnection(BasePhyConnection):
|
||||
self.__xfer(request)
|
||||
|
||||
response: List[int] = []
|
||||
deadline_ts = time.time() + self.__read_timeout
|
||||
deadline_ts = time.monotonic() + self.__read_timeout
|
||||
found = False
|
||||
while time.time() < deadline_ts:
|
||||
while time.monotonic() < deadline_ts:
|
||||
for byte in self.__xfer(b"\x00" * (5 - len(response))):
|
||||
if not found:
|
||||
if byte != 0x33:
|
||||
|
||||
@ -328,7 +328,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
assert self.__new_file
|
||||
await aiofs.afile_write_now(self.__new_file, chunk)
|
||||
self.__new_file_written += len(chunk)
|
||||
now = time.time()
|
||||
now = time.monotonic()
|
||||
if self.__new_file_tick + 1 < now:
|
||||
# Это нужно для ручного оповещения о свободном пространстве на диске, см. get_state()
|
||||
self.__new_file_tick = now
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user