ReactiveX / RxPY

ReactiveX for Python

Home Page:https://rxpy.rtfd.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to dispose observables subscribed on threadpool scheduler

AstrickHarren opened this issue · comments

Describe the bug
This code

pool = ThreadPoolScheduler()
run = rx.repeat_value(1).pipe(
    ops.subscribe_on(pool)
).subscribe()
sleep(.5)
run.dispose()

doesn't seems to be able to shutdown the repeat_value despite calling dispose.

To Reproduce
Just run the code above, you'll see the thread never ends. If it ends by OS, you can
make a debug breakpoint at ScheduledDisposable.dispose(..), (or even its init(..))
and you'll see it is never called.

  • OS [e.g. Mac Monetary]
  • RxPY version [e.g 3.2.0]
  • Python version [e.g. 3.10.2]

I think the reason may be subscribe on will call on another subscription to the repeat_value with current thread scheduler, which appears to be synchronous due to the fact it constantly schedules next repeated value, and so the disposable here is never of is never set to be ScheduledDisposable?