Skip to content

Commit

Permalink
fix(utils): 新增 requests 的 timeout
Browse files Browse the repository at this point in the history
- 避免 GitHub Action 的測試卡住
  • Loading branch information
iwtba4188 committed Dec 7, 2023
1 parent 0fc5312 commit 1b57123
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/cached_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get(url: str, cache=True, update=False, auto_headers=True, **kwargs) -> str:
else:
headers = None
url = validate_url(url)
response = requests.get(url, headers, **kwargs)
response = requests.get(url, headers, timeout=10, **kwargs)
status_code = response.status_code
if status_code != 200:
raise HTTPException(status_code, f"Request error: {status_code}")
Expand All @@ -86,7 +86,7 @@ def post(url: str, cache=True, update=False, **kwargs) -> str:
del ttl_cache[url]
if cache and url in ttl_cache:
return ttl_cache[url]
response = requests.post(url, **kwargs)
response = requests.post(url, timeout=10, **kwargs)
status_code = response.status_code
if status_code != 200:
raise HTTPException(status_code, f"Request error: {status_code}")
Expand Down

0 comments on commit 1b57123

Please sign in to comment.