zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.33k stars 284 forks source link

Allow retry period to be cancelled by context #212

Closed rtrox closed 1 year ago

rtrox commented 1 year ago

Currently, given the use of time.Sleep, retry time periods completely ignore the context passed into the function. This PR swaps the sleep logic to instead use a select and time.After, so that context cancellation will successfully cancel the sleep. The behavior in this PR is just to return the original error if context is cancelled during the retry Sleep. If you'd prefer, I can also swap to return a context cancellation, too. Signed-off-by: Russell Troxel russelltroxel@gmail.com

strideynet commented 1 year ago

Many thanks for this