Satyam Agarwal
11/15/2020, 8:47 PMevalOn
, and coroutineContexts
. Made 2 test files to show what is happening and what I expect.
https://github.com/satyamagarwal/arrow-issues/tree/master/src/test/kotlin/com/arrow/issues
Can any one help me please ? feel free to take a pull and test it out.raulraja
11/16/2020, 8:53 AMSatyam Agarwal
11/16/2020, 9:55 AMEnvironment(MDCContext()).unsafeRunSync {
Same result.
in test, key: myValue
I am in main
in runBlocking, key: myValue
I am in parTupledN, ForkJoinPool-1-worker-3
in parTupledN block, key: null
I am in parTupledN, ForkJoinPool-1-worker-5
in parTupledN block, key: null
I am in ForkJoinPool-1-worker-3
in either block, key: null
I am in ForkJoinPool-1-worker-5
in evalOn block, key: null
Evaluated thread result : ForkJoinPool-1-worker-5 in ForkJoinPool-1-worker-5
in either block after evalOn, key: null
I am in ForkJoinPool-1-worker-5
in parTupledN block after evalOn, key: null
I am in ForkJoinPool-1-worker-3
in parTupledN block after evalOn, key: null
Evaluated either block result : ForkJoinPool-1-worker-5 in ForkJoinPool-1-worker-3
in mdcContext after either block, key: null
in test, key: myValue
with original program :
in test, key: myValue
I am in main @coroutine#3
in runBlocking, key: myValue
I am in parTupledN, ForkJoinPool-1-worker-3
in parTupledN block, key: null
I am in parTupledN, ForkJoinPool-1-worker-5
in parTupledN block, key: null
I am in main @coroutine#3
in either block, key: myValue
I am in ForkJoinPool-1-worker-5
in evalOn block, key: null
Evaluated thread result : ForkJoinPool-1-worker-5 in ForkJoinPool-1-worker-5
in either block after evalOn, key: null
I am in ForkJoinPool-1-worker-3
in parTupledN block after evalOn, key: null
I am in ForkJoinPool-1-worker-3
in parTupledN block after evalOn, key: null
Evaluated either block result : ForkJoinPool-1-worker-5 in ForkJoinPool-1-worker-3
in mdcContext after either block, key: null
in test, key: myValue
raulraja
11/16/2020, 10:44 AMSatyam Agarwal
11/16/2020, 10:49 AMevalOn
hangs when ConnectionRefused is thrown ?Satyam Agarwal
11/16/2020, 10:49 AMsimon.vergauwen
11/16/2020, 11:00 AMMDCContext
is not a simple CoroutineContext
, it's a ThreadContextElement
which is a type that is hard-wired in the KotlinX library so we cananot add support for it.simon.vergauwen
11/16/2020, 11:06 AMhttps://github.com/satyamagarwal/arrow-issues/blob/26a2adfe6dfc5e920872cef52adafca3585f542e/src/test/kotlin/com/arrow/issues/CoroutinesTest.kt#L95This can be considered a bug, since
Enviroment
actually requires a ContinuationInterceptor
as an argument, which MDCContext
isn't. So we can default back to adding ComputationPool
by default if the provided CoroutineContext
isn't a ContinuationInterceptor
. That would fix the incorrect thread
reading.
The reason for this is that to go back to an original thread you need a dispatching ContinuationInterceptor
, otherwise that's not possible.
Although that still wouldn't solve the issue you're having with MDCContext
. If known this issue for quite a while, but am unsure how we can solve it best or what we can do about it. Ideally the interface would exist in the Standard libray and so all libraries that want to support it can do so but that's probably not happening soon.Satyam Agarwal
11/16/2020, 11:27 AMsimon.vergauwen
11/16/2020, 11:42 AM