]> git.ipfire.org Git - pakfire.git/commitdiff
hub: Avoid any crashes when we received no message
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 May 2022 09:41:39 +0000 (09:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 May 2022 09:41:39 +0000 (09:41 +0000)
The on_message callback can be called when the connection is closed
which made the JSON decoder crash.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/hub.py

index 2afcaff0b0c367b9eb65f82de5d33b9ea218c1e0..51d8df36756642a04a8699115d671df847d3e36e 100644 (file)
@@ -332,6 +332,10 @@ class Hub(object):
 
                        It will then call the callback with the decoded message.
                """
+               # Ignore empty messages
+               if message is None:
+                       return
+
                try:
                        message = json.loads(message)
                except json.JSONDecodeError: