From 0cfbf63eaf9bf706d1609b08f88ed08219008229 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 27 Jun 2017 10:18:35 +0200 Subject: [PATCH] Fix ConnectionResetError not flagging the socket as disconnected --- telethon/extensions/tcp_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/extensions/tcp_client.py b/telethon/extensions/tcp_client.py index 3600ac88..27cc0d93 100644 --- a/telethon/extensions/tcp_client.py +++ b/telethon/extensions/tcp_client.py @@ -96,8 +96,9 @@ class TcpClient: try: partial = self._socket.recv(bytes_left) if len(partial) == 0: + self.connected = False raise ConnectionResetError( - 'The server has closed the connection (recv() returned 0 bytes).') + 'The server has closed the connection.') buffer.write(partial) bytes_left -= len(partial)