Skip to content

Commit

Permalink
#654 fixed flickering test
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed Jun 29, 2023
1 parent 9e3abfe commit d65eb5d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/auth/oauth_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ def _schedule_token_refresh(self, username, refresh_token, next_refresh_datetime
if not self._scheduler:
self.scheduler = Scheduler()

if (next_refresh_datetime - datetime.datetime.now()) < datetime.timedelta(seconds=30):
next_refresh_datetime_adjusted = next_refresh_datetime
elif (next_refresh_datetime - datetime.datetime.now()) < datetime.timedelta(minutes=2):
token_expires_in = next_refresh_datetime - datetime.datetime.now()
if token_expires_in < datetime.timedelta(seconds=30):
next_refresh_datetime_adjusted = next_refresh_datetime - (token_expires_in / 2)
elif token_expires_in < datetime.timedelta(minutes=2):
next_refresh_datetime_adjusted = next_refresh_datetime - datetime.timedelta(seconds=10)
else:
next_refresh_datetime_adjusted = next_refresh_datetime - datetime.timedelta(minutes=1)
Expand Down

0 comments on commit d65eb5d

Please sign in to comment.