Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operators.retry(n) interferes with non-erroring repeats #712

Open
matiboy opened this issue Mar 21, 2024 · 0 comments
Open

operators.retry(n) interferes with non-erroring repeats #712

matiboy opened this issue Mar 21, 2024 · 0 comments

Comments

@matiboy
Copy link
Collaborator

matiboy commented Mar 21, 2024

Describe the bug
When using e.g. operators.retry(3) the operator will stop the emission after 3 repeats even though no error had been raised.

To Reproduce

I feel that the below test should pass, but it fails as mentioned in the comments

def test_retry_with_count_when_complete():
    scheduler = TestScheduler()
    xs = scheduler.create_cold_observable(
        on_next(90, 42), on_completed(200)
    )

    result = scheduler.start(
        lambda: xs.pipe(
            operators.retry(2), # <-- expecting this to only react when an error is thrown
            operators.repeat() # <-- when it reaches this, retry has done its job and resub-ing to source via repeat should reset the counter
        )
    )
    assert result.messages == [
        on_next(290, 42),
        on_next(490, 42),
        on_next(690, 42), # <-- expecting this and next line, but in current state, ...
        on_next(890, 42), # <-- ... these two will never be emitted as retry(2) stops source from repeating
    ]

Expected behavior
retry should not interact with the sequence unless an error is emitted. Currently it limits the number of calls to n regardless of the source observable behavior.

I understand that it may be my understanding of retry(n) which is flawed, but it seems to me like a bug. Logically retry(3) should look at the on_completed as (quoting docs):

or until it successfully terminates

So when src completes, retry(3) has done its job, and it's only when we resubscribe via repeat() that it should reset to try 3 times imo.

Code or Screenshots

See reproduction test above

Additional context

  • RxPY version: 4.0.4
  • Python version : 3.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant