Fix socket may be None when closing twice

This commit is contained in:
Lonami Exo 2018-06-20 17:59:11 +02:00
parent a0eb824e87
commit c8ee0bdca9

View File

@ -107,9 +107,10 @@ class TcpClient:
def close(self):
"""Closes the connection."""
fd = self._socket.fileno()
fd = None
try:
if self._socket is not None:
fd = self._socket.fileno()
if self.is_connected:
self._socket.shutdown(socket.SHUT_RDWR)
self._socket.close()