Ignore errors when flushing socket during close

This commit is contained in:
Kovid Goyal 2015-05-19 16:32:34 +05:30
parent 1897119a24
commit 0b1084a7b8

View File

@ -26,7 +26,7 @@ def error_codes(*errnames):
socket_error_eintr = error_codes("EINTR", "WSAEINTR") socket_error_eintr = error_codes("EINTR", "WSAEINTR")
socket_errors_to_ignore = error_codes( socket_errors_to_ignore = error_codes( # errors indicating a closed connection
"EPIPE", "EPIPE",
"EBADF", "WSAEBADF", "EBADF", "WSAEBADF",
"ENOTSOCK", "WSAENOTSOCK", "ENOTSOCK", "WSAENOTSOCK",
@ -82,7 +82,10 @@ class SocketFile(object): # {{{
def close(self): def close(self):
try: try:
if self._sock is not None: if self._sock is not None:
self.flush() try:
self.flush()
except socket.error:
pass
finally: finally:
if self._close and self._sock is not None: if self._close and self._sock is not None:
self._sock.close() self._sock.close()