From f66530ac8785c6639d2857e17c92d6ac225c56e4 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 14 Jul 2022 13:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20hotfix:=20listen=20KeyError=20bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyromod/listen/listen.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyromod/listen/listen.py b/pyromod/listen/listen.py index 81bfff4..417b445 100644 --- a/pyromod/listen/listen.py +++ b/pyromod/listen/listen.py @@ -18,7 +18,9 @@ You should have received a copy of the GNU General Public License along with pyromod. If not, see . """ + import asyncio +import contextlib import functools from typing import Optional, List, Union @@ -70,8 +72,9 @@ class Client: @patchable def clear_listener(self, chat_id, future): - if future == self.listening[chat_id]["future"]: - self.listening.pop(chat_id, None) + with contextlib.suppress(KeyError): + if future == self.listening[chat_id]["future"]: + self.listening.pop(chat_id, None) @patchable def cancel_listener(self, chat_id):