From 988f2417ea7c1f14b0392934b4d58720ee75dbd5 Mon Sep 17 00:00:00 2001 From: preeded <86511859+preeded@users.noreply.github.com> Date: Sun, 5 Dec 2021 19:14:19 +0900 Subject: [PATCH] add destructor to TCPAsyncSocketConnection class --- mcstatus/protocol/connection.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mcstatus/protocol/connection.py b/mcstatus/protocol/connection.py index ccc24c9..56ffbc3 100644 --- a/mcstatus/protocol/connection.py +++ b/mcstatus/protocol/connection.py @@ -277,8 +277,11 @@ async def read(self, length): def write(self, data): self.writer.write(data) - def close(self): - self.writer.close() + def __del__(self): + try: + self.writer.close() + except: + pass class UDPAsyncSocketConnection(AsyncReadConnection):