You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to ReactiveX/RxJava#200, it seems like merge() does not serialize emissions if its sources are emitting on different threads. Is there an RxPy equivalent to SynchronizedObserver to work around this?
I translated the unit test written for this issue, and it fails on RxPy 1.6.1 (latest in PIP).
fromthreadingimportEvent, LockfromrximportObservablefromrx.concurrencyimportEventLoopSchedulerfromrx.coreimportObservableBaseclassTestAsynchronousObservable(ObservableBase):
def__init__(self, scheduler=None):
super(TestAsynchronousObservable, self).__init__()
self.scheduler=schedulerorEventLoopScheduler()
self.on_next_being_sent=Event()
defhello(self, scheduler, observer):
self.on_next_being_sent.set()
observer.on_next("hello")
observer.on_completed()
def_subscribe_core(self, observer):
self.scheduler.schedule(self.hello, observer)
counter_lock=Lock()
total_counter=0concurrent_counter=0unblock=Event()
completed=Event()
defon_next(item):
globalcounter_lockglobaltotal_counterglobalconcurrent_counterglobalunblockwithcounter_lock:
total_counter+=1concurrent_counter+=1unblock.wait()
concurrent_counter-=1o1=TestAsynchronousObservable()
o2=TestAsynchronousObservable()
m=Observable.merge(o1, o2).subscribe(on_next, on_completed=completed.set)
# Wait for both Observables to send.o1.on_next_being_sent.wait()
o2.on_next_being_sent.wait()
# One of the Observables should be blocked.assertconcurrent_counter==1# <-- Asserts here since merge() does not serialize the on_next() calls.# Release it so it can finish.unblock.set()
# Wait for the merge to complete.completed.wait()
asserttotal_counter==2assertconcurrent_counter==0
The text was updated successfully, but these errors were encountered:
Similar to ReactiveX/RxJava#200, it seems like merge() does not serialize emissions if its sources are emitting on different threads. Is there an RxPy equivalent to SynchronizedObserver to work around this?
I translated the unit test written for this issue, and it fails on RxPy 1.6.1 (latest in PIP).
ReactiveX/RxJava@effc08d#diff-e28fd5678569ef71dfc9e835c73a5c36R42
The text was updated successfully, but these errors were encountered: