From 46ef3d4d0a23369f5016c5c41c388a55309174c6 Mon Sep 17 00:00:00 2001 From: tursom <tursom@foxmail.com> Date: Fri, 11 Oct 2024 18:09:08 +0800 Subject: [PATCH] update --- live_status_ntf.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/live_status_ntf.py b/live_status_ntf.py index 9d56dc2..dad44fd 100644 --- a/live_status_ntf.py +++ b/live_status_ntf.py @@ -64,7 +64,10 @@ class MyHandler(FileSystemEventHandler): room.position = os.path.getsize(event.src_path) for line in f: - data = json.loads(line) + try: + data = json.loads(line) + except json.decoder.JSONDecodeError: + continue self._handle_data(room, data) self._check_room_state_change(room) @@ -81,7 +84,10 @@ class MyHandler(FileSystemEventHandler): with open(event.src_path, "r", encoding="utf-8") as f: for line in f: - data = json.loads(line) + try: + data = json.loads(line) + except json.decoder.JSONDecodeError: + continue self._handle_data(data) self._check_room_state_change(room)