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
Member

@paramsingh paramsingh commented Nov 1, 2018

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

mayhem
mayhem approved these changes Nov 1, 2018
Copy link
Member

@mayhem mayhem left a comment

Minor tweaks needed, feel free to merge afterwards.

Loading

@@ -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

@mayhem mayhem Nov 1, 2018

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.

Loading

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

@mayhem mayhem Nov 1, 2018

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:...

Loading

@paramsingh paramsingh merged commit 1f2923a into metabrainz:master Nov 1, 2018
1 check passed
Loading
@paramsingh paramsingh deleted the spotify-refresh-token-error branch Nov 1, 2018
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