From 8e5fbadc58ee2606f3433dcdbadeaa285b5cb410 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 28 Jul 2014 22:35:49 +0200 Subject: [PATCH] socket error handling --- lib/util.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/util.py b/lib/util.py index eed6f066..71dc31b8 100644 --- a/lib/util.py +++ b/lib/util.py @@ -287,27 +287,24 @@ class SocketPipe: def _send(self, out): while out: try: - sent = self.socket.send( out ) + sent = self.socket.send(out) out = out[sent:] except ssl.SSLError as e: - print_error( "SSLError: retry", e) + print_error("SSLError:", e) time.sleep(0.1) continue - except socket.error as e: if e[0] in (errno.EWOULDBLOCK,errno.EAGAIN): - print_error( "EAGAIN: retrying") + print_error("EAGAIN: retrying") time.sleep(0.1) continue - elif e[0] == 'The write operation timed out': - print_error( "ssl: retry") + elif e[0] in ['timed out', 'The write operation timed out']: + print_error("socket timeout, retry") time.sleep(0.1) continue else: - print repr(e[0]) traceback.print_exc(file=sys.stdout) - print_error( "Not connected, cannot send" ) - return False + raise e