From 5f770451716e0ae7c9ba84d7be764f316955e1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9F?= Date: Fri, 13 Oct 2023 10:59:58 +0200 Subject: [PATCH] reduce page size on timeout errors in slack api calls --- backend/danswer/connectors/slack/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/danswer/connectors/slack/utils.py b/backend/danswer/connectors/slack/utils.py index ba1bf3fd885..f7932e1ad8e 100644 --- a/backend/danswer/connectors/slack/utils.py +++ b/backend/danswer/connectors/slack/utils.py @@ -95,7 +95,15 @@ def rate_limited_call(**kwargs: Any) -> SlackResponse: # Raise the error for non-transient errors raise except TimeoutError as e: - logger.info(f"Slack call timed out, retrying. Exception: {e}") + if "limit" in kwargs: + kwargs["limit"] = int(kwargs["limit"] / 2) + if kwargs["limit"] < 1: + kwargs["limit"] = 1 + logger.info( + f"Slack call timed out, retrying with limit {kwargs['limit']}. Exception: {e}" + ) + else: + logger.info(f"Slack call timed out, retrying. Exception: {e}") time.sleep(3) # If the code reaches this point, all retries have been exhausted