This is an automated email from the ASF dual-hosted git repository.
bossenti pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 85c0e3ac01 Catch json decode error (#2554)
85c0e3ac01 is described below
commit 85c0e3ac01dc9ba8945c784ae368c66f14cb0bc0
Author: Sven Oehler <[email protected]>
AuthorDate: Thu Mar 14 11:45:45 2024 +0100
Catch json decode error (#2554)
---
streampipes-client-python/streampipes/functions/function_handler.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git
a/streampipes-client-python/streampipes/functions/function_handler.py
b/streampipes-client-python/streampipes/functions/function_handler.py
index deb2fc0818..4eaceb1754 100644
--- a/streampipes-client-python/streampipes/functions/function_handler.py
+++ b/streampipes-client-python/streampipes/functions/function_handler.py
@@ -134,7 +134,11 @@ class FunctionHandler:
if stream_id == "stop":
break
for streampipes_function in
self.stream_contexts[stream_id].functions:
- streampipes_function.onEvent(json.loads(msg.data.decode()),
stream_id)
+ msg_str = msg.data.decode()
+ try:
+ streampipes_function.onEvent(json.loads(msg_str),
stream_id)
+ except json.JSONDecodeError:
+ logger.warn(f"Message isn't in json format: {msg_str}")
# Stop the functions
self._stop_functions()