From c7c77c85973eefd03fa7172ab207651f476f8fe0 Mon Sep 17 00:00:00 2001 From: naisanzaa Date: Mon, 20 Nov 2023 09:57:18 -0800 Subject: [PATCH] facebook: fix rate limiter --- automon/integrations/facebook/groups.py | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/automon/integrations/facebook/groups.py b/automon/integrations/facebook/groups.py index ad4dcbcb..fb621ac3 100644 --- a/automon/integrations/facebook/groups.py +++ b/automon/integrations/facebook/groups.py @@ -472,20 +472,23 @@ def get_with_rate_limiter( result = None while retry < retries: - if not self.rate_limited(): - - result = self.get(url=url) - - if self.rate_limited(): - self.rate_limit_increase() - result = False - self._rate_counter.append(self._wait_between_retries) - Sleeper.seconds(seconds=self._wait_between_retries) - else: - log.info(f'{result}') - self.rate_limit_decrease() - self.screenshot_success() - return result + if self.rate_limited(): + self.rate_limit_increase() + + self._rate_counter.append(self._wait_between_retries) + Sleeper.seconds(seconds=self._wait_between_retries) + log.error(str(dict( + url=url, + retry=retry, + retries=retries, + ))) + continue + + result = self.get(url=url) + log.info(f'{result}') + self.rate_limit_decrease() + self.screenshot_success() + return result retry = retry + 1