Error handling improvement in sendDataThread
- don't uncecessarily report EPIPE as a big error, just close the connection
This commit is contained in:
parent
ea9f10a8bb
commit
fef6126a74
|
@ -77,7 +77,7 @@ class sendDataThread(threading.Thread):
|
||||||
def sendBytes(self, data = ""):
|
def sendBytes(self, data = ""):
|
||||||
self.buffer += data
|
self.buffer += data
|
||||||
if len(self.buffer) < throttle.SendThrottle().chunkSize and self.sendDataThreadQueue.qsize() > 1:
|
if len(self.buffer) < throttle.SendThrottle().chunkSize and self.sendDataThreadQueue.qsize() > 1:
|
||||||
return
|
return True
|
||||||
|
|
||||||
while self.buffer and state.shutdown == 0:
|
while self.buffer and state.shutdown == 0:
|
||||||
isSSL = False
|
isSSL = False
|
||||||
|
@ -104,16 +104,18 @@ class sendDataThread(threading.Thread):
|
||||||
select.select([], [self.sslSock if isSSL else self.sock], [], 10)
|
select.select([], [self.sslSock if isSSL else self.sock], [], 10)
|
||||||
logger.debug('sock.recv retriable error')
|
logger.debug('sock.recv retriable error')
|
||||||
continue
|
continue
|
||||||
|
if e.errno in (errno.EPIPE):
|
||||||
|
logger.debug('Connection broken')
|
||||||
|
return False
|
||||||
raise
|
raise
|
||||||
throttle.SendThrottle().wait(amountSent)
|
throttle.SendThrottle().wait(amountSent)
|
||||||
self.lastTimeISentData = int(time.time())
|
self.lastTimeISentData = int(time.time())
|
||||||
self.buffer = self.buffer[amountSent:]
|
self.buffer = self.buffer[amountSent:]
|
||||||
|
return True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
logger.debug('sendDataThread starting. ID: ' + str(id(self)) + '. Number of queues in sendDataQueues: ' + str(len(state.sendDataQueues)))
|
logger.debug('sendDataThread starting. ID: ' + str(id(self)) + '. Number of queues in sendDataQueues: ' + str(len(state.sendDataQueues)))
|
||||||
while True:
|
while self.sendBytes():
|
||||||
self.sendBytes()
|
|
||||||
deststream, command, data = self.sendDataThreadQueue.get()
|
deststream, command, data = self.sendDataThreadQueue.get()
|
||||||
|
|
||||||
if deststream == 0 or deststream in self.streamNumber:
|
if deststream == 0 or deststream in self.streamNumber:
|
||||||
|
|
Reference in New Issue
Block a user