[GH-ISSUE #717] Exponential backoff timer #431

Closed
opened 2026-02-27 23:22:36 +03:00 by kerem · 3 comments
Owner

Originally created by @systemcrash on GitHub (Aug 18, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/717

Is your feature request related to a problem? Please describe.
HASS spams the API endpoint with multiple worker threads, despite continuous 429 responses.

Describe the solution you'd like
How about an exponential back-off timer?

Describe alternatives you've considered
Death. 💀

Additional context
HASS approach is to turn a bit of a blind eye here, e.g. https://github.com/home-assistant/core/issues/53776 and who can blame them when they suspect that it's a Spotify issue.

To alleviate the risk of hidden bugs here or there or anywhere, try an exponential backoff.

I was not able to remove and re-add the Spotify add-on in HASS, until

  1. completely having removed the extension
  2. having waited for about 15-20 minutes
  3. trying again anew

The 429s may be rooted in another problem on their side if they do not provide an adequate Retry-After: header. But I don't want to get banned from the API endpoint, nor would HASS want to, so a logarithmic back-off would be reassuring.

If multiple workers run spotipy to retry, it might be a futile effort (since there may be overlap of retry via HASS worker threads), but if the existing thread backs off, it should help.


ERROR (SyncWorker_6) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_7) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_1) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_1) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_8) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_6) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_2) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_4) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_2) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_8) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_8) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30
ERROR (SyncWorker_2) [spotipy.client] Max Retries reached
WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds
Originally created by @systemcrash on GitHub (Aug 18, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/717 **Is your feature request related to a problem? Please describe.** HASS spams the API endpoint with multiple worker threads, despite continuous 429 responses. **Describe the solution you'd like** How about an exponential back-off timer? **Describe alternatives you've considered** Death. 💀 **Additional context** HASS approach is to turn a bit of a blind eye here, e.g. https://github.com/home-assistant/core/issues/53776 and who can blame them when they suspect that it's a Spotify issue. To alleviate the risk of hidden bugs here or there or anywhere, try an exponential backoff. I was not able to remove and re-add the Spotify add-on in HASS, until 1) completely having removed the extension 2) having waited for about 15-20 minutes 3) trying again anew The 429s may be rooted in another problem on their side if they do not provide an adequate `Retry-After:` header. But I don't want to get banned from the API endpoint, nor would HASS want to, so a logarithmic back-off would be reassuring. If multiple workers run spotipy to retry, it might be a futile effort (since there may be overlap of retry via HASS worker threads), but if the existing thread backs off, it should help. ``` ERROR (SyncWorker_6) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_7) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_1) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_1) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_8) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_6) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_2) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_4) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_2) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_8) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_8) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds WARNING (MainThread) [homeassistant.components.media_player] Updating spotify media_player took longer than the scheduled update interval 0:00:30 ERROR (SyncWorker_2) [spotipy.client] Max Retries reached WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spotify_blah_blah is taking over 10 seconds ```
kerem 2026-02-27 23:22:36 +03:00
Author
Owner

@systemcrash commented on GitHub (Aug 18, 2021):

Oops - I see it's already there......

<!-- gh-comment-id:901062091 --> @systemcrash commented on GitHub (Aug 18, 2021): Oops - I see it's already there......
Author
Owner

@systemcrash commented on GitHub (Aug 18, 2021):

Is it possible that the Retry-After header contains an http-date and not just delay-seconds ?

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After

In which case it is the responsibility of urllib3?

<!-- gh-comment-id:901063242 --> @systemcrash commented on GitHub (Aug 18, 2021): Is it possible that the Retry-After header contains an http-date and not just delay-seconds ? https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After In which case it is the responsibility of urllib3?
Author
Owner

@systemcrash commented on GitHub (Aug 18, 2021):

Nope - they support it. Hmmmm.

<!-- gh-comment-id:901065960 --> @systemcrash commented on GitHub (Aug 18, 2021): Nope - they support it. Hmmmm.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#431
No description provided.