Skip to content

Commit

Permalink
increase sleep time with every retry
Browse files Browse the repository at this point in the history
  • Loading branch information
BeritJanssen committed Jan 16, 2025
1 parent df19c10 commit 08c5bfe
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/corpora/gallica/gallica.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def sources(self, start: datetime, end: datetime):
if int(year.string) >= start.year and int(year.string) <= end.year
]
for year in years:
for _n in range(self.n_retries):
sleep(30)
for retry in range(self.n_retries):
sleep(retry * 10)
try:
response = requests.get(
f"{self.data_url}/services/Issues?ark=ark:/12148/{self.corpus_id}/date&date={year}"
Expand All @@ -79,13 +79,13 @@ def sources(self, start: datetime, end: datetime):
break
except RequestsConnectionError:
logger.warning(
f"Connection error when processing year {year}, going to sleep"
f"Connection error when processing year {year}, going to sleep for {retry * 10} seconds"
)
continue

for ark in ark_numbers:
for _n in range(self.n_retries):
sleep(30)
for retry in range(self.n_retries):
sleep(retry * 10)
try:
source_response = requests.get(
f"{self.data_url}/services/OAIRecord?ark={ark}"
Expand All @@ -94,11 +94,11 @@ def sources(self, start: datetime, end: datetime):
break
except RequestsConnectionError:
logger.warning(
f"Connection error encountered in issue {ark}, going to sleep"
f"Connection error encountered in issue {ark}, going to sleep for {retry * 10} seconds"
)
continue
for _n in range(self.n_retries):
sleep(30)
for retry in range(self.n_retries):
sleep(retry * 10)
try:
content_response = requests.get(
f"{self.data_url}/ark:/12148/{ark}.texteBrut"
Expand All @@ -110,7 +110,7 @@ def sources(self, start: datetime, end: datetime):
break
except RequestsConnectionError:
logger.warning(
f"Connection error when fetching full text of issue {ark}, going to sleep"
f"Connection error when fetching full text of issue {ark}, going to sleep for {retry * 10} seconds"
)
continue
yield (
Expand Down

0 comments on commit 08c5bfe

Please sign in to comment.