From 278f0e9e983d938589b6d541e71135ad5b6857c5 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 10 May 2019 18:54:10 +0200 Subject: [PATCH] Don't raise errors during disconnect --- telethon/network/connection/connection.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/network/connection/connection.py b/telethon/network/connection/connection.py index 5fffaeb2..22a4b11f 100644 --- a/telethon/network/connection/connection.py +++ b/telethon/network/connection/connection.py @@ -110,7 +110,12 @@ class Connection(abc.ABC): if self._writer: self._writer.close() if sys.version_info >= (3, 7): - await self._writer.wait_closed() + try: + await self._writer.wait_closed() + except Exception as e: + # Seen OSError: No route to host + # Disconnecting should never raise + self._log.warning('Unhandled %s on disconnect: %s', type(e), e) def send(self, data): """