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 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 left a comment

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

This comment has been minimized.

Copy link
@mayhem

mayhem Nov 1, 2018

Member

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:

This comment has been minimized.

Copy link
@mayhem

mayhem Nov 1, 2018

Member

Or just if new_token:...

@paramsingh paramsingh merged commit 1f2923a into metabrainz:master Nov 1, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@paramsingh paramsingh deleted the paramsingh: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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.