mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Prevent double-logging of 'timeout for updates'
This commit is contained in:
parent
362d06654f
commit
dd55e7c748
|
@ -250,7 +250,10 @@ class MessageBox:
|
|||
elif self.next_deadline in self.map:
|
||||
deadline = min(deadline, self.map[self.next_deadline].deadline)
|
||||
|
||||
if now > deadline:
|
||||
# asyncio's loop time precision only seems to be about 3 decimal places, so it's possible that
|
||||
# we find the same number again on repeated calls. Without the "or equal" part we would log the
|
||||
# timeout for updates several times (it also makes sense to get difference if now is the deadline).
|
||||
if now >= deadline:
|
||||
# Check all expired entries and add them to the list that needs getting difference.
|
||||
self.getting_diff_for.update(entry for entry, gap in self.possible_gaps.items() if now > gap.deadline)
|
||||
self.getting_diff_for.update(entry for entry, state in self.map.items() if now > state.deadline)
|
||||
|
|
|
@ -335,13 +335,15 @@ class UpdateMethods:
|
|||
continue
|
||||
|
||||
deadline = self._message_box.check_deadlines()
|
||||
try:
|
||||
updates = await asyncio.wait_for(
|
||||
self._updates_queue.get(),
|
||||
deadline - asyncio.get_running_loop().time()
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
self._log[__name__].info('Timeout waiting for updates expired')
|
||||
deadline_delay = deadline - asyncio.get_running_loop().time()
|
||||
if deadline_delay > 0:
|
||||
# Don't bother sleeping and timing out if the delay is already 0 (pollutes the logs).
|
||||
try:
|
||||
updates = await asyncio.wait_for(self._updates_queue.get(), deadline_delay)
|
||||
except asyncio.TimeoutError:
|
||||
self._log[__name__].info('Timeout waiting for updates expired')
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
||||
processed = []
|
||||
|
|
Loading…
Reference in New Issue
Block a user