Skip to content

Replace backoff with a plain retry loop - #1556

Merged
frenck merged 1 commit into
mainfrom
frenck/drop-backoff
Oct 1, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/drop-backoff

Conversation

@frenck

@frenck frenck commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Breaking change

None. Requests are retried exactly as before.

Proposed change

backoff has not seen a release since 2022, and on Python 3.14 it emits deprecation warnings for asyncio.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 of random.uniform(0, 2**attempt) seconds in between. That is the same exponential backoff with full jitter that backoff.expo gave us, and it drops a dependency.

It also cleans up the tests. Patching backoff's sleep meant patching asyncio.sleep for everything, since backoff calls it through the asyncio module. The tests now patch only the retry wait in radios.radio_browser, and a new test checks the wait ceilings (1, 2, 4 and 8 seconds).

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

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.
@frenck frenck added the refactor Improvement of existing code, not introducing new features. label Oct 1, 2026
@frenck
frenck merged commit 37735d4 into main Oct 1, 2026
31 checks passed
@frenck
frenck deleted the frenck/drop-backoff branch October 1, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Improvement of existing code, not introducing new features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant