Conversation
The retry(n) generator was created once at observable creation time and shared across all subscriptions. When combined with repeat(), the retry pool was exhausted after n total subscriptions regardless of errors, causing repeat() to resubscribe to an empty generator that immediately completed. Fix: create the generator inside the subscribe closure so each subscription gets a fresh retry budget. This matches the expected ReactiveX semantics where retry(n) means 'on error, resubscribe up to n times per subscription'. Closes #712 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ae29c2b to
7820458
Compare
…tion-2b9941042da6d10e
This was referenced Apr 20, 2026
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fixes
retry(n)interacting incorrectly withrepeat()(issue #712).Root Cause
The retry generator (
range(n)orinfinite()) was created once at observable creation time and shared across all subscriptions:catch_with_iterablestoresiter(sources)at construction, so the iterator is shared. Whenrepeat()resubscribes toretry(n), the iterator may already be fully consumed, causingcatch_with_iterableto immediately callobserver.on_completed()without subscribing to the source. This triggeredrepeat()again in a tight loop that produced no values after the nth subscription.Fix
Move the generator creation inside the
subscribeclosure so each subscription gets a fresh retry budget:This matches the expected ReactiveX semantics:
retry(n)means "on error, resubscribe up to n times per subscription attempt". Each invocation fromrepeat()is a new subscription and should start with a full retry allowance.Changes
reactivex/operators/_retry.py: wrap logic insubscribeclosuretests/test_observable/test_retry.py: add regression test forretry(n) + repeat()changes.md: add changelog entry; also resolve lingering merge-conflict markersTesting
All 10 tests pass (
pytest tests/test_observable/test_retry.py). The new testtest_retry_with_count_combined_with_repeatreproduces the exact scenario from issue #712 and verifies the fix.Closes #712
Note
🔒 Integrity filter blocked 67 items
The following items were blocked because they don't meet the GitHub integrity level.
list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".tapoperator #750list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".AsyncIOScheduler.nowreturns a datetime in 1970. #734list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".now()implementation breaksschedule_absolute()compatibility. #724list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: