Close the hddtemp socket in the finally block

This way we avoid leaving sockets open which can trigger a
ResourceWarning in some cases.
This commit is contained in:
Alessio Sergi 2016-03-11 18:20:20 +01:00
parent 45820e9183
commit ebd5f60962

View File

@ -130,12 +130,13 @@ class GlancesGrabHDDTemp(object):
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.connect((self.host, self.port))
data = sck.recv(4096)
sck.close()
except socket.error as e:
logger.warning("Can not connect to an HDDtemp server ({0}:{1} => {2})".format(self.host, self.port, e))
logger.debug("Disable the HDDtemp module. Use the --disable-hddtemp to hide the previous message.")
self.args.disable_hddtemp = True
data = ""
finally:
sck.close()
return data