You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by oe...@apache.org on 2024/03/13 16:54:03 UTC

(streampipes) branch 2553-streampipes-python-functions-error-for-not-started-adapter updated: Catch json decode error

This is an automated email from the ASF dual-hosted git repository.

oehler pushed a commit to branch 2553-streampipes-python-functions-error-for-not-started-adapter
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/2553-streampipes-python-functions-error-for-not-started-adapter by this push:
     new 0e4733c367 Catch json decode error
0e4733c367 is described below

commit 0e4733c367df8560f782d2b0816b5a0f65e328e7
Author: Sven Oehler <oe...@web.de>
AuthorDate: Wed Mar 13 17:53:12 2024 +0100

    Catch json decode error
---
 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()