From 8e5221cfe9107a3898ff8ab69d19b5f32c26dde0 Mon Sep 17 00:00:00 2001
From: Gaetan Lepage <gaetan.lepage@inria.fr>
Date: Mon, 29 Nov 2021 14:09:41 +0100
Subject: [PATCH] [backend] better handling of unparseable messages from the
 data fetcher

---
 rl_hm/backend/main.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/rl_hm/backend/main.py b/rl_hm/backend/main.py
index 40136c8..a6da8b1 100644
--- a/rl_hm/backend/main.py
+++ b/rl_hm/backend/main.py
@@ -39,8 +39,11 @@ def _update_loop(socket_io: socketio.Server,
 
         try:
             payload_dict = json.loads(decoded_string)
-        except json.decoder.JSONDecodeError:
+        except json.decoder.JSONDecodeError as json_exception:
             # if the received data is corrupted, just ignore this packet
+            LOGGER.error("JSONDecodeError while parsing received payload: %s", str(json_exception))
+            LOGGER.error("received payload: %s", decoded_string)
+
             continue
 
         source: str = payload_dict.pop('source')
@@ -78,7 +81,6 @@ def callback_disconnect(*args) -> None:
 def main() -> None:
 
     # Run the update loop that gets updates from the data fetcher.
-    # It keeps the local `STATE_DICT` updated
     socket_io.start_background_task(target=_update_loop,
                                     socket_io=socket_io,
                                     data_fetcher_socket=data_fetcher_socket)
-- 
GitLab