Skip to content

Commit

Permalink
Retry for certain non-blocking operations
Browse files Browse the repository at this point in the history
- sometimes on read, EWOULDBLOCK is returned. It should retry. A timeout
  is handled separately
  • Loading branch information
PeterSurda committed Feb 6, 2017
1 parent 61770ba commit ddc0ca5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/class_receiveDataThread.py
Expand Up @@ -100,13 +100,13 @@ def run(self):
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
Expand Down

0 comments on commit ddc0ca5

Please sign in to comment.