Attempt at making get_new_msg_id thread-safe (#195)

This commit is contained in:
Lonami Exo 2017-08-14 15:15:18 +02:00
parent 1794acdfec
commit 7e85a3cda4

View File

@ -234,10 +234,12 @@ class JsonSession:
# "message identifiers are divisible by 4"
new_msg_id = (int(now) << 32) | (nanoseconds << 2)
with self._lock:
if self._last_msg_id >= new_msg_id:
new_msg_id = self._last_msg_id + 4
self._last_msg_id = new_msg_id
return new_msg_id
def update_time_offset(self, correct_msg_id):