Skip to content

Commit

Permalink
tweak network timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
gsfk committed Aug 12, 2024
1 parent 378a3e8 commit 8b320d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions bento_beacon/network/network_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
"https://ichange.bento.sd4h.ca/api/beacon",
# "https://qa.bento.sd4h.ca/api/beacon/",
# "https://bentov2.local/api/beacon",
# "https://renata.bento.sd4h.ca/api/beacon",
"https://renata.bento.sd4h.ca/api/beacon",
"https://signature.bento.sd4h.ca/api/beacon",
# "https://bentov2.local/api/beacon"
]

NETWORK_TIMEOUT = 30
NETWORK_INIT_TIMEOUT = 30
NETWORK_QUERY_WITH_VARIANTS_TIMEOUT = 2 * 60
NETWORK_QUERY_WITHOUT_VARIANTS_TIMEOUT = 30

VALID_ENDPOINTS = ["analyses", "biosamples", "cohorts", "datasets", "g_variants", "individuals", "runs", "overview"]

Expand Down
6 changes: 3 additions & 3 deletions bento_beacon/network/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
from urllib.parse import urlsplit, urlunsplit
from json import JSONDecodeError
from .network_config import BEACONS, NETWORK_TIMEOUT
from .network_config import BEACONS, NETWORK_INIT_TIMEOUT
from ..utils.exceptions import APIException, InvalidQuery
from ..utils.beacon_response import beacon_count_response

Expand All @@ -18,9 +18,9 @@
def network_beacon_call(method, url, payload=None):
try:
if method == "GET":
r = requests.get(url, timeout=NETWORK_TIMEOUT)
r = requests.get(url, timeout=NETWORK_INIT_TIMEOUT)
else:
r = requests.post(url, json=payload, timeout=NETWORK_TIMEOUT)
r = requests.post(url, json=payload, timeout=NETWORK_INIT_TIMEOUT)
beacon_response = r.json()

except (requests.exceptions.RequestException, JSONDecodeError) as e:
Expand Down

0 comments on commit 8b320d7

Please sign in to comment.