From 992017ddf8eb3d9fcc70ff82761acdea4260ecb6 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 22 Dec 2017 11:27:57 +0100 Subject: [PATCH] Except ConnectionAbortedError on TcpClient --- telethon/extensions/tcp_client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/extensions/tcp_client.py b/telethon/extensions/tcp_client.py index 3941a4d6..9a007dcd 100644 --- a/telethon/extensions/tcp_client.py +++ b/telethon/extensions/tcp_client.py @@ -113,7 +113,7 @@ class TcpClient: self._socket.sendall(data) except socket.timeout as e: raise TimeoutError() from e - except BrokenPipeError: + except (BrokenPipeError, ConnectionAbortedError): self._raise_connection_reset() except OSError as e: if e.errno == errno.EBADF: @@ -139,6 +139,11 @@ class TcpClient: partial = self._socket.recv(bytes_left) except socket.timeout as e: raise TimeoutError() from e + except ConnectionAbortedError: + # ConnectionAbortedError: [WinError 10053] + # An established connection was aborted by + # the software in your host machine. + self._raise_connection_reset() except OSError as e: if e.errno == errno.EBADF or e.errno == errno.ENOTSOCK: self._raise_connection_reset()