From 31b9671e7b7b347db37176a8b9408b74dfda60e4 Mon Sep 17 00:00:00 2001 From: Vignesh Rao Date: Sat, 14 Dec 2024 17:44:57 -0600 Subject: [PATCH] Fix intermittent launch error due to IP connectivity --- jarvis/executors/internet.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jarvis/executors/internet.py b/jarvis/executors/internet.py index 2eb2e8be..51f0ec58 100644 --- a/jarvis/executors/internet.py +++ b/jarvis/executors/internet.py @@ -74,13 +74,14 @@ def public_ip_info() -> Dict[str, str]: dict: Public IP information. """ + # todo: Identify usage and try to use looping and try several hosts try: - return json.load(urllib.request.urlopen(url="https://ipinfo.io/json")) - except (urllib.error.HTTPError, urllib.error.URLError) as error: + return json.load(urllib.request.urlopen(url="https://ipinfo.io/json", timeout=3)) + except Exception as error: logger.error(error) try: - return json.loads(urllib.request.urlopen(url="http://ip.jsontest.com").read()) - except (urllib.error.HTTPError, urllib.error.URLError) as error: + return json.loads(urllib.request.urlopen(url="http://ip.jsontest.com", timeout=3).read()) + except Exception as error: logger.error(error)