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: if self.connected:
self._socket.shutdown(socket.SHUT_RDWR) self._socket.shutdown(socket.SHUT_RDWR)
self._socket.close() self._socket.close()
except OSError as e: except OSError:
if e.errno != errno.ENOTCONN: pass # Ignore ENOTCONN, EBADF, and any other error when closing
raise
finally: finally:
self._socket = None self._socket = None