Skip to content

Commit 030b928

Browse files
authored
Merge pull request #1803 from codeforpdx/issue-1710/add-retries-to-case-loading
[Enhancement] - Issue-1710/Add Retries to Case Loading
2 parents d85f7d0 + 74b0c01 commit 030b928

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/backend/expungeservice/endpoints/case_detail_page.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from os import path
22
from pathlib import Path
3+
import time
34

45
from bs4 import BeautifulSoup
56
from flask.views import MethodView
@@ -10,11 +11,19 @@
1011
class CaseDetailPage(MethodView):
1112
def get(self, id):
1213
url = f"https://publicaccess.courts.oregon.gov/PublicAccessLogin/CaseDetail.aspx?CaseID={id}"
13-
html = Crawler.fetch_link(url)
14-
if html:
15-
return CaseDetailPage._strip_links(html)
16-
else:
17-
return f"Case detail page with ID of {id} does not exist."
14+
15+
max_retries = 3
16+
backoff_seconds = 2
17+
# Retry loop with backoff
18+
for attempt in range(max_retries):
19+
html = Crawler.fetch_link(url)
20+
if html:
21+
return CaseDetailPage._strip_links(html)
22+
23+
if attempt < max_retries - 1:
24+
time.sleep(backoff_seconds)
25+
26+
return f"Case detail page with ID of {id} does not exist."
1827

1928
@staticmethod
2029
def _strip_links(html):

0 commit comments

Comments
 (0)