diff --git a/src/class_sendDataThread.py b/src/class_sendDataThread.py index 3d35c48a..552cbffc 100644 --- a/src/class_sendDataThread.py +++ b/src/class_sendDataThread.py @@ -201,7 +201,11 @@ class sendDataThread(threading.Thread): elif self.connectionIsOrWasFullyEstablished: logger.error('sendDataThread ID: ' + str(id(self)) + ' ignoring command ' + command + ' because the thread is not in stream ' + str(deststream) + ' but in streams ' + ', '.join(str(x) for x in self.streamNumber)) self.sendDataThreadQueue.task_done() - self.sendDataThreadQueue.task_done() + # Flush if the cycle ended with break + try: + self.sendDataThreadQueue.task_done() + except ValueError + pass try: self.sock.shutdown(socket.SHUT_RDWR) diff --git a/src/class_singleListener.py b/src/class_singleListener.py index 0a8c4a93..f41a9724 100644 --- a/src/class_singleListener.py +++ b/src/class_singleListener.py @@ -86,7 +86,7 @@ class singleListener(threading.Thread, StoppableThread): # we'll fall back to IPv4-only. try: sock = self._createListenSocket(socket.AF_INET6) - except socket.error, e: + except socket.error as e: if (isinstance(e.args, tuple) and e.args[0] in (errno.EAFNOSUPPORT, errno.EPFNOSUPPORT, @@ -112,7 +112,15 @@ class singleListener(threading.Thread, StoppableThread): self.stop.wait(10) while state.shutdown == 0: - socketObject, sockaddr = sock.accept() + try: + socketObject, sockaddr = sock.accept() + except socket.error as e: + if isinstance(e.args, tuple) and + e.args[0] in (errno.EINTR,): + continue + time.wait(1) + continue + (HOST, PORT) = sockaddr[0:2] # If the address is an IPv4-mapped IPv6 address then