Skip to content

Commit

Permalink
fix: define timeout for connection check
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoFgrx committed Aug 29, 2024
1 parent d7f5c9d commit e1159bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions utils/challenge_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions utils/instance_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit e1159bb

Please sign in to comment.