From 0b1084a7b84812dd7a6033af66091c1c5eff6268 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 May 2015 16:32:34 +0530 Subject: [PATCH] Ignore errors when flushing socket during close --- src/calibre/srv/loop.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/srv/loop.py b/src/calibre/srv/loop.py index 3cb15a8746..9ce205db1c 100644 --- a/src/calibre/srv/loop.py +++ b/src/calibre/srv/loop.py @@ -26,7 +26,7 @@ def error_codes(*errnames): 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", "EBADF", "WSAEBADF", "ENOTSOCK", "WSAENOTSOCK", @@ -82,7 +82,10 @@ class SocketFile(object): # {{{ def close(self): try: if self._sock is not None: - self.flush() + try: + self.flush() + except socket.error: + pass finally: if self._close and self._sock is not None: self._sock.close()