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()