From 2abe5217aa4b05911b5be237f6a159b6d0290c6f Mon Sep 17 00:00:00 2001 From: Terrtia Date: Tue, 15 Jun 2021 17:19:57 +0200 Subject: [PATCH] fix: [Splash_Manager errors] catch invalid response --- bin/lib/crawlers.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/lib/crawlers.py b/bin/lib/crawlers.py index 81837e39..913ee7c1 100755 --- a/bin/lib/crawlers.py +++ b/bin/lib/crawlers.py @@ -1055,12 +1055,17 @@ def ping_splash_manager(): update_splash_manager_connection_status(True) return True else: - res = req.json() - if 'reason' in res: - req_error = {'status_code': req.status_code, 'error': res['reason']} - else: - print(req.json()) - req_error = {'status_code': req.status_code, 'error': json.dumps(req.json())} + try: + res = req.json() + if 'reason' in res: + req_error = {'status_code': req.status_code, 'error': res['reason']} + else: + print(req.json()) + req_error = {'status_code': req.status_code, 'error': json.dumps(req.json())} + except json.decoder.JSONDecodeError: + print(req.status_code) + print(req.headers) + req_error = {'status_code': req.status_code, 'error': 'Invalid response'} update_splash_manager_connection_status(False, req_error=req_error) return False except requests.exceptions.ConnectionError: