-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Allow for thread interruption #593
Conversation
… interruptions Conflicts: hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java
NetflixOSS » Hystrix » Hystrix-pull-requests #15 FAILURE |
Hystrix-pull-requests #254 FAILURE |
Also note that Javanica tests are failing as a result. It wasn't obvious to me what went wrong there, so I might need help from Javanica experts after we sort out the code in hystrix-core |
Hystrix-pull-requests #255 FAILURE |
NetflixOSS » Hystrix » Hystrix-pull-requests #16 FAILURE |
@abersnaze already got 1 of these merged into RxJava master: ReactiveX/RxJava#2575. This addresses the issue where unsubscription was not propagated properly in OperatorSubscribeOn |
@mattrjacobs I had to revert that PR because it was a no-op in RxJava at best because RxJava's workers track all scheduled tasks and thus unsubscribing the worker while having a task is equivalent of unsubscribing the task. See this test which schedules a bunch of tasks and cancels them all at once with a single unsubscription; the test then shows that no task was retained. Looking at HystrixCommandScheduler the task-scheduling logic is quite old and has several races (is it even used?). The Edit: I've checked the documentation of |
Thanks for taking a look @akarnokd , I appreciate it. Yes, the Scheduler being used is the I am now looking through the examples of concrete |
Closing this in favor of #647 |
This PR addresses #354, but I would like feedback before I consider merging. Especially from @benjchristensen / @abersnaze.
All of the unit tests that are added (Thanks @aadeon!) now pass, but I would love to see a better way to accomplish this goal.
It's hacky in a few ways:
Observable.subscribeOn
method has a bug where unsubscription is not propagated to the work which is submitted to the new Scheduler. ASubscription
is generated inOperatorSubscribeOn
in theschedule()
method and then forgotten about. I believe that's the preciseSubscription
we need to unsubscribe from.Subscriptions.from(Future<?> f)
wraps aFuture
and upon unsubscription, cancels this future. It hardcodes the parameter to cancel, however. This is the value we need to have drawn from theHystrixCommandProperties
. So I believe that we should consider adding this to RxJava proper, rather than the hack I've done here. That hack is to not call thecreateWorker()
in theScheduler
interface, but cast theScheduler
to aHystrixContextScheduler
and call its (new)createWorker(boolean shouldInterrupt)
method. Since this is really only valid for thread pools, I'm not sure how much of this belongs in theScheduler
interface.