From dcdaa5ff5232ca04746d5b6075c82444102eaa26 Mon Sep 17 00:00:00 2001 From: Kevin Tindall Date: Mon, 22 Aug 2022 08:42:29 -0500 Subject: [PATCH] Ignore socket failure to close during del --- mcstatus/protocol/connection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mcstatus/protocol/connection.py b/mcstatus/protocol/connection.py index 048154b7..884c2cde 100644 --- a/mcstatus/protocol/connection.py +++ b/mcstatus/protocol/connection.py @@ -513,7 +513,10 @@ def close(self) -> None: def __del__(self) -> None: """Close self.socket.""" - self.close() + try: + self.close() + except OSError: # Probably, the socket was already closed by the OS + pass class TCPSocketConnection(SocketConnection):