Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry some times while trying to refresh user tokens #448

Merged

Conversation

paramsingh
Copy link
Collaborator

There was a sentry error for this in the Spotify importer.

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor tweaks needed, feel free to merge afterwards.

@@ -68,7 +68,17 @@ def refresh_user_token(spotify_user):
user (domain.spotify.Spotify): the same user with updated tokens
"""
auth = get_spotify_oauth()
new_token = auth.refresh_access_token(spotify_user.refresh_token)

retries = 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either make this a config or a constant we can define at the top. Burying this in the code is no good.

new_token = None
while retries > 0:
new_token = auth.refresh_access_token(spotify_user.refresh_token)
if new_token is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just if new_token:...

@paramsingh paramsingh merged commit 1f2923a into metabrainz:master Nov 1, 2018
@paramsingh paramsingh deleted the spotify-refresh-token-error branch November 1, 2018 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants