示例#1
0
 def __init__(self) -> None:
     self._subject = Subject()
     self._scheduler = ThreadPoolScheduler(max_workers=1)
     obs = self._subject.pipe(ops.observe_on(self._scheduler))
     self._disposable = obs \
         .pipe(ops.window_with_time_or_count(count=5, timespan=datetime.timedelta(milliseconds=10_000)),
               ops.flat_map(lambda x: self._window_to_group(x)),
               ops.map(mapper=lambda x: self._retryable(data=x, delay=self._jitter_delay(jitter_interval=1000))),
               ops.merge_all()) \
         .subscribe(self._result, self._error, self._on_complete)
     pass
示例#2
0
    def test_observe_on_forward_subscribe_scheduler(self):
        scheduler = ImmediateScheduler()
        expected_subscribe_scheduler = ImmediateScheduler()

        actual_subscribe_scheduler = None

        def subscribe(observer, scheduler):
            nonlocal actual_subscribe_scheduler
            actual_subscribe_scheduler = scheduler
            observer.on_completed()

        xs = reactivex.create(subscribe)

        xs.pipe(ops.observe_on(scheduler)).subscribe(
            scheduler=expected_subscribe_scheduler)

        assert expected_subscribe_scheduler == actual_subscribe_scheduler
示例#3
0
 def create():
     return xs.pipe(ops.observe_on(scheduler))