Replace monotonic() with perf_counter()
It seems like monotonic() goes out of sync after some time.
This commit is contained in:
parent
c689273167
commit
5e3f2ab947
@ -18,19 +18,19 @@
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from time import monotonic
|
||||
from time import perf_counter
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MsgId:
|
||||
reference_clock = monotonic()
|
||||
reference_clock = perf_counter()
|
||||
last_time = 0
|
||||
msg_id_offset = 0
|
||||
server_time = 0
|
||||
|
||||
def __new__(cls) -> int:
|
||||
now = monotonic() - cls.reference_clock + cls.server_time
|
||||
now = perf_counter() - cls.reference_clock + cls.server_time
|
||||
cls.msg_id_offset = cls.msg_id_offset + 4 if now == cls.last_time else 0
|
||||
msg_id = int(now * 2 ** 32) + cls.msg_id_offset
|
||||
cls.last_time = now
|
||||
|
Loading…
Reference in New Issue
Block a user