ReactiveX / RxPY

ReactiveX for Python
https://rxpy.rtfd.io
MIT License
4.81k stars 361 forks source link

fix: windowwithtimeorcount thread unsafe #700

Open fanck0605 opened 1 year ago

fanck0605 commented 1 year ago

We expect them to be equal, but they are not

result = []
(
    reactivex.range(100_000)
    .pipe(
        operators.buffer_with_time_or_count(timespan=0.001, count=10_000),
    )
    .subscribe(on_next=lambda x: result.extend(x))
)
print(f"len(result) = {len(result)}")
assert result == [*range(100_000)]

Result:

len(result) = 99986
Traceback (most recent call last):
  File "D:\Projects\效能提升\rxdemo\test_retry.py", line 16, in <module>
    assert result == [*range(100_000)]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError