From c54f19282a9fc214e1eea3bbc80d572cbe93cef3 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 19 Jul 2020 19:00:26 +0200 Subject: [PATCH] improved error handling, refs #146 #22 --- owrx/audio.py | 2 +- owrx/connection.py | 5 ++++- owrx/websocket.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/owrx/audio.py b/owrx/audio.py index a8c2880..b77ad7c 100644 --- a/owrx/audio.py +++ b/owrx/audio.py @@ -240,5 +240,5 @@ class AudioChopper(threading.Thread, metaclass=ABCMeta): try: readers = wait([w.outputReader for w in self.writers]) return [r.recv() for r in readers] - except EOFError: + except (EOFError, OSError): return None diff --git a/owrx/connection.py b/owrx/connection.py index 8e3407d..f3e951e 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -41,7 +41,10 @@ class Client(ABC): threading.Thread(target=mp_passthru).start() def send(self, data): - self.conn.send(data) + try: + self.conn.send(data) + except IOError: + self.close() def close(self): self.conn.close() diff --git a/owrx/websocket.py b/owrx/websocket.py index fc6462d..de34141 100644 --- a/owrx/websocket.py +++ b/owrx/websocket.py @@ -16,7 +16,7 @@ OPCODE_PING = 0x09 OPCODE_PONG = 0x0A -class WebSocketException(Exception): +class WebSocketException(IOError): pass