mirror of
https://github.com/Dinnerbone/mcstatus.git
synced 2026-04-06 12:01:24 +08:00
Implicitly close sockets in destructor methods
This commit is contained in:
@@ -149,6 +149,9 @@ class TCPSocketConnection(Connection):
|
||||
def write(self, data):
|
||||
self.socket.send(data)
|
||||
|
||||
def __del__(self):
|
||||
self.socket.close()
|
||||
|
||||
|
||||
class UDPSocketConnection(Connection):
|
||||
def __init__(self, addr, timeout=3):
|
||||
@@ -176,3 +179,6 @@ class UDPSocketConnection(Connection):
|
||||
if isinstance(data, Connection):
|
||||
data = bytearray(data.flush())
|
||||
self.socket.sendto(data, self.addr)
|
||||
|
||||
def __del__(self):
|
||||
self.socket.close()
|
||||
Reference in New Issue
Block a user