Skip to content

Commit

Permalink
Don't immediately stop polling on auth errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 1, 2023
1 parent 90d9c7c commit 4e53a43
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mautwitdm/poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class TwitterPoller(TwitterDispatcher):
poll_sleep: int = 3
error_sleep: int = 5
max_poll_errors: int = 12
max_poll_auth_errors: int = 4
poll_cursor: str | None
dispatch_initial_resp: bool
_poll_task: asyncio.Task | None
Expand Down Expand Up @@ -297,10 +298,13 @@ async def _poll_forever(self) -> None:
self.log.debug(f"Increased poll sleep to {self.poll_sleep}")
await asyncio.sleep(sleep)
continue
except TwitterAuthError:
raise
except Exception as e:
if errors > self.max_poll_errors > 0:
max_errors = (
self.max_poll_auth_errors
if isinstance(e, TwitterAuthError)
else self.max_poll_errors
)
if errors > max_errors > 0:
self.log.debug(
f"Error count ({errors}) exceeded maximum, raising error as fatal"
)
Expand Down

0 comments on commit 4e53a43

Please sign in to comment.