mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-01-09 14:27:10 +00:00
call socket's close() even when shutdown causes an exception, fixes hopefully #65 for good
This commit is contained in:
parent
25e550d3fe
commit
79f3b447c8
@ -62,12 +62,13 @@ class TPLinkSmartHomeProtocol:
|
|||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
sock.shutdown(socket.SHUT_RDWR)
|
sock.shutdown(socket.SHUT_RDWR)
|
||||||
sock.close()
|
|
||||||
except OSError:
|
except OSError:
|
||||||
# OSX raises OSError when shutdown() gets called on a closed
|
# OSX raises OSError when shutdown() gets called on a closed
|
||||||
# socket. We ignore it here as the data has already been read
|
# socket. We ignore it here as the data has already been read
|
||||||
# into the buffer at this point.
|
# into the buffer at this point.
|
||||||
pass
|
pass
|
||||||
|
finally:
|
||||||
|
sock.close()
|
||||||
|
|
||||||
response = TPLinkSmartHomeProtocol.decrypt(buffer[4:])
|
response = TPLinkSmartHomeProtocol.decrypt(buffer[4:])
|
||||||
_LOGGER.debug("< (%i) %s", len(response), response)
|
_LOGGER.debug("< (%i) %s", len(response), response)
|
||||||
|
Loading…
Reference in New Issue
Block a user