Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add retries into the annotator class #319

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/dug/core/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,16 @@ def annotate(self, text, http_session):
def make_request(self, value: Input, http_session: Session):
value = urllib.parse.quote(value)
url = f'{self.url}{value}'
response = http_session.get(url)

# This could be moved to a config file
NUM_TRIES = 5
for _ in range(NUM_TRIES):
response = http_session.get(url)
if response is not None:
# looks like it worked
break

# if the reponse is still None here, throw an error
if response is None:
raise RuntimeError(f"no response from {url}")
return response.json()
Expand Down
Loading