From ddc0ca5ede66ae8c74115e590f133e6e2027a82e Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 6 Feb 2017 19:41:25 +0100 Subject: [PATCH] Retry for certain non-blocking operations - sometimes on read, EWOULDBLOCK is returned. It should retry. A timeout is handled separately --- src/class_receiveDataThread.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/class_receiveDataThread.py b/src/class_receiveDataThread.py index 43a48fc7..efa0092a 100644 --- a/src/class_receiveDataThread.py +++ b/src/class_receiveDataThread.py @@ -100,13 +100,13 @@ class receiveDataThread(threading.Thread): logger.error ('Timeout occurred waiting for data from ' + str(self.peer) + '. Closing receiveData thread. (ID: ' + str(id(self)) + ')') break except socket.error as err: -# if err.errno == 2 or (sys.platform == 'win32' and err.errno == 10035) or (sys.platform != 'win32' and err.errno == errno.EWOULDBLOCK): -# if ssl: -# select.select([self.sslSock], [], []) -# else: -# select.select([self.sock], [], []) -# logger.error('sock.recv retriable error') -# continue + if err.errno == errno.EWOULDBLOCK: + if ssl: + select.select([self.sslSock], [], [], 10) + else: + select.select([self.sock], [], [], 10) + logger.error('sock.recv retriable error') + continue logger.error('sock.recv error. Closing receiveData thread (' + str(self.peer) + ', Thread ID: ' + str(id(self)) + ').' + str(err.errno) + "/" + str(err)) if self.initiatedConnection and not self.connectionIsOrWasFullyEstablished: shared.timeOffsetWrongCount += 1