Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sources/bin/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ def read_suite_per_tool_id(tool_fp: str) -> Dict:
return tools


def get_request_json(url: str, headers: dict, retries: int = 3, delay: float = 2.0) -> dict:
def get_request_json(url: str, headers: dict, retries: int = 7, delay: float = 2.0) -> dict:
"""
Perform a GET request to retrieve JSON output from a specified URL, with retry on ConnectionError.

:param url: URL to send the GET request to.
:param headers: Headers to include in the GET request.
:param retries: Number of retry attempts in case of a ConnectionError (default is 3).
:param delay: Delay in seconds between retries (default is 2.0 seconds).
:param retries: Number of retry attempts in case of a ConnectionError (default is 7).
:param delay: Delay in seconds between retries (default is 2.0 seconds), now multiplied by the number of attempt to increase delay as number of attempt increases.
:return: JSON response as a dictionary, or None if all retries fail.
:raises ConnectionError: If all retry attempts fail due to a connection error.
:raises SystemExit: For any other request-related errors.
Expand All @@ -136,8 +136,8 @@ def get_request_json(url: str, headers: dict, retries: int = 3, delay: float = 2
raise ConnectionError(
"Connection aborted after multiple retries: Remote end closed connection without response"
) from e
print(f"Connection error on attempt {attempt}/{retries}. Retrying in {delay} seconds...")
time.sleep(delay) # Wait before retrying
print(f"Connection error on attempt {attempt}/{retries}. Retrying in {delay**attempt} seconds...")
time.sleep(delay**attempt) # Wait before retrying, wait time increases as number of attempt increases
except requests.exceptions.RequestException as e:
# Handles all other exceptions from the requests library
raise SystemExit(f"Request failed: {e}")
Expand Down