Skip to content

Commit 74b0c01

Browse files
committed
Adjust get function logic for CaseDetailPage with a retry loop
1 parent d85f7d0 commit 74b0c01

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

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)