From a7f98fd3cc2abdd6935eef69c5a8251b0756ca4a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 2 Mar 2018 17:26:42 +0100 Subject: [PATCH] Ignore bad file descriptor while closing --- telethon/extensions/tcp_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telethon/extensions/tcp_client.py b/telethon/extensions/tcp_client.py index d9cea2f0..d335e57a 100644 --- a/telethon/extensions/tcp_client.py +++ b/telethon/extensions/tcp_client.py @@ -168,7 +168,10 @@ class TcpClient: __log__.info('ConnectionError "%s" while reading data', e) self._raise_connection_reset(e) except OSError as e: - __log__.info('OSError "%s" while reading data', e) + if e.errno != errno.EBADF and self._closing_lock.locked(): + # Ignore bad file descriptor while closing + __log__.info('OSError "%s" while reading data', e) + if e.errno in CONN_RESET_ERRNOS: self._raise_connection_reset(e) else: