socket error handling

This commit is contained in:
ThomasV 2014-07-28 22:35:49 +02:00
parent 640a6a3bf9
commit 8e5fbadc58
1 changed files with 6 additions and 9 deletions

View File

@ -287,27 +287,24 @@ class SocketPipe:
def _send(self, out): def _send(self, out):
while out: while out:
try: try:
sent = self.socket.send( out ) sent = self.socket.send(out)
out = out[sent:] out = out[sent:]
except ssl.SSLError as e: except ssl.SSLError as e:
print_error( "SSLError: retry", e) print_error("SSLError:", e)
time.sleep(0.1) time.sleep(0.1)
continue continue
except socket.error as e: except socket.error as e:
if e[0] in (errno.EWOULDBLOCK,errno.EAGAIN): if e[0] in (errno.EWOULDBLOCK,errno.EAGAIN):
print_error( "EAGAIN: retrying") print_error("EAGAIN: retrying")
time.sleep(0.1) time.sleep(0.1)
continue continue
elif e[0] == 'The write operation timed out': elif e[0] in ['timed out', 'The write operation timed out']:
print_error( "ssl: retry") print_error("socket timeout, retry")
time.sleep(0.1) time.sleep(0.1)
continue continue
else: else:
print repr(e[0])
traceback.print_exc(file=sys.stdout) traceback.print_exc(file=sys.stdout)
print_error( "Not connected, cannot send" ) raise e
return False