mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-28 22:55:55 +03:00
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:
parent
45820e9183
commit
ebd5f60962
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user