From 0c3e2cb68df875656c8b08ae0943605291c6aba6 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Thu, 10 Mar 2022 11:15:25 +0100 Subject: [PATCH] feat(api): changed live check --- api/chalicelib/core/assist.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/api/chalicelib/core/assist.py b/api/chalicelib/core/assist.py index aee8a97f5..70f563ec8 100644 --- a/api/chalicelib/core/assist.py +++ b/api/chalicelib/core/assist.py @@ -71,7 +71,18 @@ def get_live_sessions_ws(project_id): print("!! issue with the peer-server") print(connected_peers.text) return [] - live_peers = connected_peers.json().get("data", []) + try: + live_peers = connected_peers.json().get("data", []) + except Exception as e: + print("issue getting Live-Assist response") + print(str(e)) + print("expected JSON, received:") + try: + print(connected_peers.text) + except: + print("couldn't get response") + live_peers = [] + for s in live_peers: s["live"] = True s["projectId"] = project_id @@ -95,7 +106,17 @@ def is_live(project_id, session_id, project_key=None): print("!! issue with the peer-server") print(connected_peers.text) return False - connected_peers = connected_peers.json().get("data", []) + try: + connected_peers = connected_peers.json().get("data", []) + except Exception as e: + print("issue getting Assist response") + print(str(e)) + print("expected JSON, received:") + try: + print(connected_peers.text) + except: + print("couldn't get response") + return False return str(session_id) in connected_peers