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()