mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Attempt at making get_new_msg_id thread-safe (#195)
This commit is contained in:
parent
1794acdfec
commit
7e85a3cda4
|
@ -234,10 +234,12 @@ class JsonSession:
|
||||||
# "message identifiers are divisible by 4"
|
# "message identifiers are divisible by 4"
|
||||||
new_msg_id = (int(now) << 32) | (nanoseconds << 2)
|
new_msg_id = (int(now) << 32) | (nanoseconds << 2)
|
||||||
|
|
||||||
if self._last_msg_id >= new_msg_id:
|
with self._lock:
|
||||||
new_msg_id = self._last_msg_id + 4
|
if self._last_msg_id >= new_msg_id:
|
||||||
|
new_msg_id = self._last_msg_id + 4
|
||||||
|
|
||||||
|
self._last_msg_id = new_msg_id
|
||||||
|
|
||||||
self._last_msg_id = new_msg_id
|
|
||||||
return new_msg_id
|
return new_msg_id
|
||||||
|
|
||||||
def update_time_offset(self, correct_msg_id):
|
def update_time_offset(self, correct_msg_id):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user