Repository navigation
Replace backoff with a plain retry loop - #1556
Merged
Merged
Conversation
backoff has not seen a release since 2022 and warns about deprecated asyncio APIs on Python 3.14. A small loop does the same job: five attempts, with an exponentially growing wait and full jitter in between, just like backoff.expo did. It also lets the tests patch only the retry wait. Patching backoff's sleep replaced asyncio.sleep everywhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
None. Requests are retried exactly as before.
Proposed change
backoffhas not seen a release since 2022, and on Python 3.14 it emits deprecation warnings forasyncio.iscoroutinefunction, which is slated for removal in Python 3.16.The retry logic it provided is small enough to own:
_request()is now a plain loop around_request_once(), with five attempts and a wait ofrandom.uniform(0, 2**attempt)seconds in between. That is the same exponential backoff with full jitter thatbackoff.expogave us, and it drops a dependency.It also cleans up the tests. Patching backoff's sleep meant patching
asyncio.sleepfor everything, since backoff calls it through theasynciomodule. The tests now patch only the retry wait inradios.radio_browser, and a new test checks the wait ceilings (1, 2, 4 and 8 seconds).Type of change
Additional information
Checklist
poetry run pytestpasses locally. A pull request cannot be merged unless CI is green.poetry run prek run --all-filespasses (lint, format, and type checks).