From dde01cc9b98abc98dce076caa998bd8f1de57a14 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 18 Dec 2017 13:50:00 +0100 Subject: [PATCH] Fix unhandled exception in case the connection is already closed --- pyrogram/connection/transport/tcp/tcp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyrogram/connection/transport/tcp/tcp.py b/pyrogram/connection/transport/tcp/tcp.py index a8fca46c..0a799d39 100644 --- a/pyrogram/connection/transport/tcp/tcp.py +++ b/pyrogram/connection/transport/tcp/tcp.py @@ -33,8 +33,12 @@ class TCP(socket.socket): pass def close(self): - self.shutdown(socket.SHUT_RDWR) - super().close() + try: + self.shutdown(socket.SHUT_RDWR) + except OSError: + pass + finally: + super().close() def recvall(self, length: int) -> bytes or None: data = b""