diff --git a/__init__.py b/__init__.py index 0f4488d..9e120c6 100644 --- a/__init__.py +++ b/__init__.py @@ -69,7 +69,7 @@ def admin_settings(): try: logger.debug("getting connection status with chall-manager") - requests.get(get_config("chall-manager:chall-manager_api_url")) + requests.get(get_config("chall-manager:chall-manager_api_url"), timeout=5) except Exception as e: logger.warning(f"cannot communicate with CM provided got {e}") cm_api_reachable = False diff --git a/utils/challenge_store.py b/utils/challenge_store.py index 62ad437..fb0c79d 100644 --- a/utils/challenge_store.py +++ b/utils/challenge_store.py @@ -20,7 +20,7 @@ def query_challenges() -> list: logger.debug(f"Querying challenges from {url}") try: - with s.get(url, headers=None, stream=True) as resp: + with s.get(url, headers=None, stream=True, timeout=10) as resp: for line in resp.iter_lines(): if line: res = line.decode("utf-8") @@ -112,7 +112,7 @@ def get_challenge(id: int) -> requests.Response: logger.debug(f"Getting challenge information for id={id}") try: - r = requests.get(url) + r = requests.get(url, timeout=10) logger.debug(f"Received response: {r.status_code} {r.text}") except Exception as e: logger.error(f"Error getting challenge: {e}") diff --git a/utils/instance_manager.py b/utils/instance_manager.py index 9841349..54354aa 100644 --- a/utils/instance_manager.py +++ b/utils/instance_manager.py @@ -86,7 +86,7 @@ def get_instance(challengeId: int, sourceId: int) -> requests.Response | Excepti logger.debug(f"Getting instance information for challengeId={challengeId}, sourceId={sourceId}") try: - r = requests.get(url) + r = requests.get(url, timeout=10) logger.debug(f"Received response: {r.status_code} {r.text}") except Exception as e: logger.error(f"Error getting instance: {e}") @@ -150,7 +150,7 @@ def query_instance(sourceId: int) -> list | Exception: logger.debug(f"Querying instances for sourceId={sourceId}") try: - with s.get(url, headers=None, stream=True) as resp: + with s.get(url, headers=None, stream=True, timeout=10) as resp: for line in resp.iter_lines(): if line: res = line.decode("utf-8")