Skip to content

Commit

Permalink
facebook: fix rate limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Nov 20, 2023
1 parent 411db5c commit c7c77c8
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions automon/integrations/facebook/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c7c77c8

Please sign in to comment.