From 74e922a10c4ead58e83d274cf0a2b3cb132680ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Mon, 4 Apr 2022 20:33:10 +0200 Subject: [PATCH] fix websocket error --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 9c407c36..760717c9 100755 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ from io import BytesIO from http import HTTPStatus from websocket import create_connection +from websocket._exceptions import WebSocketConnectionClosedException from PIL import Image from loguru import logger @@ -191,7 +192,11 @@ def get_board(self, access_token_in): ) ) while True: - msg = ws.recv() + try: + msg = ws.recv() + except WebSocketConnectionClosedException as e: + logger.error(e) + continue if msg is None: logger.error("Reddit failed to acknowledge connection_init") exit()