Skip to content

Commit

Permalink
fix: Add timeout to requests.get
Browse files Browse the repository at this point in the history
  • Loading branch information
saattrupdan committed Sep 29, 2024
1 parent 6d408d0 commit 9d7579e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tts_text/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ def get_soup(
html = ""
retries_left -= 1
else:
response = rq.get(url=url)
response = rq.get(url=url, timeout=10)

# Retry if the request timed out
retries_left = 5
while response.status_code == 408:
time.sleep(1)
response = rq.get(url=url)
response = rq.get(url=url, timeout=10)
retries_left -= 1
if retries_left == 0:
raise TimeoutError("The request timed out.")
Expand Down

0 comments on commit 9d7579e

Please sign in to comment.