From 290a18404de605b88d60dd97c979e7722a41f4a3 Mon Sep 17 00:00:00 2001 From: Howard Date: Wed, 6 Sep 2023 16:34:59 -0400 Subject: [PATCH] fix: Add retries into the annotator class --- src/dug/core/annotate.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dug/core/annotate.py b/src/dug/core/annotate.py index 5f7977c..7a84d71 100644 --- a/src/dug/core/annotate.py +++ b/src/dug/core/annotate.py @@ -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()