Ignore EBADF when closing the socket

This commit is contained in:
Lonami Exo 2017-09-03 13:44:29 +02:00
parent 68cdc9eaf1
commit 626778bd32

View File

@ -56,9 +56,8 @@ class TcpClient:
if self.connected:
self._socket.shutdown(socket.SHUT_RDWR)
self._socket.close()
except OSError as e:
if e.errno != errno.ENOTCONN:
raise
except OSError:
pass # Ignore ENOTCONN, EBADF, and any other error when closing
finally:
self._socket = None