Version 2.3.8

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-09-12 13:20:59 +02:00
parent fe34c1e76d
commit 5f0eaf2e62

View File

@ -40,26 +40,26 @@ class Client(object):
async def start_websocket(self, consumer): async def start_websocket(self, consumer):
s = "%s/events" % self.websocket s = "%s/events" % self.websocket
while True: async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws:
try: while True:
async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws: try:
async for msg in ws: async for msg in ws:
try: try:
await consumer(msg) await consumer(msg)
except Exception as ex: except Exception as ex:
logging.debug("Error while parsing event (%s)", ex) logging.debug("Error while parsing event (%s)", ex)
except websockets.ConnectionClosedError: except websockets.ConnectionClosedError:
logging.error("Lost websocket connection. Reconnecting...") logging.error("Lost websocket connection. Reconnecting...")
continue continue
except websockets.WebSocketException as wex: except websockets.WebSocketException as wex:
logging.error("Websocket exception (%s)", wex) logging.error("Websocket exception (%s)", wex)
continue continue
except OSError as e: except OSError as e:
logging.error("Websocket OSError exception (%s) with parameter %s", e, s) logging.error("Websocket OSError exception (%s) with parameter %s", e, s)
continue continue
except Exception as e: except Exception as e:
logging.error("Other exception (%s) with parameter %s", e, s) logging.error("Other exception (%s) with parameter %s", e, s)
continue continue
def run(self, command, verbose_errors=True): def run(self, command, verbose_errors=True):
for _ in range(0,2): for _ in range(0,2):