From 41c96fd33249adb7ecb2bbd9e45be69f6a0ed8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Sat, 3 Feb 2018 12:51:13 +0100 Subject: [PATCH] Catch exceptions while trying to close the socket. --- matrix/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/matrix/server.py b/matrix/server.py index 7ffedd7..2e94f91 100644 --- a/matrix/server.py +++ b/matrix/server.py @@ -316,8 +316,11 @@ class MatrixServer: def _close_socket(self): # type: (socket.socket) -> None if self.socket: - self.socket.shutdown(socket.SHUT_RDWR) - self.socket.close() + try: + self.socket.shutdown(socket.SHUT_RDWR) + self.socket.close() + except OSError: + pass def disconnect(self, reconnect=True): # type: (MatrixServer) -> None