-
Notifications
You must be signed in to change notification settings - Fork 363
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
Sample does not appear to emit on_completed
#645
Comments
Please submit a minimal self contained code example. Minimal means that there should not be any other code. E.g what is |
Looks like you're not giving the sample the time to emit because main thread dies. import reactivex
from reactivex import operators
subject = reactivex.Subject()
subject.pipe(
operators.sample(2.5*1e-2)
).subscribe(
on_next=lambda x: print('NEXT', x),
on_completed=lambda: print('I am complete')
)
# this has no effect on the story
def feed_subject(s: reactivex.Subject):
for i in range(8):
s.on_next(f'Hello World {i}')
time.sleep(1e-2)
feed_subject(subject)
subject.on_completed()
time.sleep(1e-3) # <--- change this to 0.1 and you'll see the on_completed The reason for this is that def test_issue_645_reproduce():
scheduler = TestScheduler()
subject = reactivex.Subject()
scheduler.schedule_relative(6.5, lambda *_: subject.on_completed())
results = scheduler.start(
lambda: subject.pipe(
operators.sample(2.5)
), created=0.01, subscribed=0.5, disposed=20
)
assert results.messages == [
on_completed(8)
] Tbh I don't know if that's supposed to be the case though. Or whether on source completion, sample should emit completion immediately. |
Following up on this, looking at RxJS specs it looks like the expected behaviour is to complete if source completes and even drop any value during the last (incomplete) sample. I've reproduced the test and it indeed fails. @dbrattli I would think this is a bug, or at least an inconsistency with RxJS (sorry that's my "reference" library, can't really find the tests in other languages) |
Describe the bug
It appears to me that running
operators.sample
prevents theon_completed
event from getting fired, whileon_error
works as expected.To Reproduce
Steps to reproduce the behavior:
operators.sample
filter.on_completed
Expected behavior
on_completed
is correctly called.Code or Screenshots
ObserverMainWindow
is a function that looks something like:Additional context
I apologize in advance if I'm missing something obvious.
Fedora 36
4.0.0
3.10.4
Edits
The text was updated successfully, but these errors were encountered: