From fef6126a74c296aa796af80b97eddd65cec93bdb Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 21 Feb 2017 09:58:28 +0100 Subject: [PATCH] Error handling improvement in sendDataThread - don't uncecessarily report EPIPE as a big error, just close the connection --- src/class_sendDataThread.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/class_sendDataThread.py b/src/class_sendDataThread.py index 7defb634..320cb932 100644 --- a/src/class_sendDataThread.py +++ b/src/class_sendDataThread.py @@ -77,7 +77,7 @@ class sendDataThread(threading.Thread): def sendBytes(self, data = ""): self.buffer += data if len(self.buffer) < throttle.SendThrottle().chunkSize and self.sendDataThreadQueue.qsize() > 1: - return + return True while self.buffer and state.shutdown == 0: isSSL = False @@ -104,16 +104,18 @@ class sendDataThread(threading.Thread): select.select([], [self.sslSock if isSSL else self.sock], [], 10) logger.debug('sock.recv retriable error') continue + if e.errno in (errno.EPIPE): + logger.debug('Connection broken') + return False raise throttle.SendThrottle().wait(amountSent) self.lastTimeISentData = int(time.time()) self.buffer = self.buffer[amountSent:] - + return True def run(self): logger.debug('sendDataThread starting. ID: ' + str(id(self)) + '. Number of queues in sendDataQueues: ' + str(len(state.sendDataQueues))) - while True: - self.sendBytes() + while self.sendBytes(): deststream, command, data = self.sendDataThreadQueue.get() if deststream == 0 or deststream in self.streamNumber: