From a38170d26a2cec89badf2d3a0db735276eb5c628 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 30 May 2022 13:28:22 +0200 Subject: [PATCH] Assert reset_deadline is not unnecessarily called --- telethon/_updates/messagebox.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/telethon/_updates/messagebox.py b/telethon/_updates/messagebox.py index d54178fc..8b1a39da 100644 --- a/telethon/_updates/messagebox.py +++ b/telethon/_updates/messagebox.py @@ -266,9 +266,8 @@ class MessageBox: # # It also updates the next deadline time to reflect the new closest deadline. def reset_deadline(self, entry, deadline): - if entry in self.map: - self.map[entry].deadline = deadline - # TODO figure out why not in map may happen + if entry not in self.map: + raise RuntimeError('Called reset_deadline on an entry for which we do not have state') if self.next_deadline == entry: # If the updated deadline was the closest one, recalculate the new minimum. @@ -464,6 +463,8 @@ class MessageBox: # the "no updates" period for that entry is reset. # # Build the `HashSet` to avoid calling `reset_deadline` more than once for the same entry. + # + # By the time this method returns, self.map will have an entry for which we can reset its deadline. if reset_deadline: self.reset_deadlines_for.add(pts.entry)