From c48d41d99d3005e530a3edbc2cea89faac7cc5cf Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 6 Dec 2018 16:27:09 +0100 Subject: [PATCH] Expect ConnectionError in the send loop --- telethon/network/connection/connection.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/telethon/network/connection/connection.py b/telethon/network/connection/connection.py index 1c43c2fc..5421358e 100644 --- a/telethon/network/connection/connection.py +++ b/telethon/network/connection/connection.py @@ -136,9 +136,12 @@ class Connection(abc.ABC): await self._writer.drain() except asyncio.CancelledError: pass - except Exception: - msg = 'Unexpected exception in the send loop' - __log__.exception(msg) + except Exception as e: + if isinstance(e, ConnectionError): + __log__.info('The server closed the connection while sending') + else: + __log__.exception('Unexpected exception in the send loop') + self.disconnect() async def _recv_loop(self):