Skip to content

Commit

Permalink
Merge pull request #40 from ternaustralia/edmond/add-timeout
Browse files Browse the repository at this point in the history
Add timeout to requests
  • Loading branch information
edmondchuc authored Oct 6, 2022
2 parents cbea718 + 6e5fe54 commit 4d96af5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/linkeddata_api/data/sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def post(
"content-type": "application/sparql-query",
}

response = requests.post(url=sparql_endpoint, headers=headers, data=query)
response = requests.post(url=sparql_endpoint, headers=headers, data=query, timeout=60)

try:
response.raise_for_status()
Expand Down Expand Up @@ -51,7 +51,7 @@ def get(
}
params = {"query": query}

response = requests.get(url=sparql_endpoint, headers=headers, params=params)
response = requests.get(url=sparql_endpoint, headers=headers, params=params, timeout=60)

try:
response.raise_for_status()
Expand Down
2 changes: 1 addition & 1 deletion src/linkeddata_api/domain/curie.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get(uri: str):
base_uri = uri[:r_index]

response = requests.post(
"https://prefix.zazuko.com/api/v1/shrink", params={"q": base_uri}
"https://prefix.zazuko.com/api/v1/shrink", params={"q": base_uri}, timeout=60
)

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def get(ontology_id: str) -> List[schema.ClassItem]:
"content-type": "application/sparql-query",
}

r = requests.post(url=mapping["sparql_endpoint"], headers=headers, data=query)
r = requests.post(
url=mapping["sparql_endpoint"], headers=headers, data=query, timeout=60
)

try:
r.raise_for_status()
Expand Down

0 comments on commit 4d96af5

Please sign in to comment.