Skip to content

Commit aa937a7

Browse files
YoilyLdelivrance
authored andcommitted
fixed memory leak when session.send coroutine is cancelled (pyrogram#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
1 parent 8f0b8ba commit aa937a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pyrogram/session/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ async def _send(self, data: TLObject, wait_response: bool = True, timeout: float
382382
await asyncio.wait_for(self.results[msg_id].event.wait(), timeout)
383383
except asyncio.TimeoutError:
384384
pass
385-
386-
result = self.results.pop(msg_id).value
385+
finally:
386+
result = self.results.pop(msg_id).value
387387

388388
if result is None:
389389
raise TimeoutError

0 commit comments

Comments
 (0)