From 4ff7ac6b75a3a0fba44c83a499a421143b8f8714 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 2 Jun 2023 19:04:39 +0200 Subject: [PATCH] Handle CancelledError inside mtprotosender recv loop --- telethon/network/mtprotosender.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/telethon/network/mtprotosender.py b/telethon/network/mtprotosender.py index c1a839d9..86e2f9fa 100644 --- a/telethon/network/mtprotosender.py +++ b/telethon/network/mtprotosender.py @@ -503,6 +503,8 @@ class MTProtoSender: self._log.debug('Receiving items from the network...') try: body = await self._connection.recv() + except asyncio.CancelledError: + raise # bypass except Exception except IOError as e: self._log.info('Connection closed while receiving data') self._start_reconnect(e)