From aa937a704d0bad9fdf2f893b2a85cc1a9a40d9b4 Mon Sep 17 00:00:00 2001 From: YoilyL Date: Mon, 9 Sep 2019 16:56:57 +0300 Subject: [PATCH] fixed memory leak when session.send coroutine is cancelled (#311) added that when session.send coroutine is cancelled (or if any other exception is raised) the result should still be removed from the results list --- pyrogram/session/session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index b5f69081..3dbedef4 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -382,8 +382,8 @@ class Session: await asyncio.wait_for(self.results[msg_id].event.wait(), timeout) except asyncio.TimeoutError: pass - - result = self.results.pop(msg_id).value + finally: + result = self.results.pop(msg_id).value if result is None: raise TimeoutError