https://kotlinlang.org logo
Title
a

ansman

03/13/2019, 9:10 PM
What’s the idiomatic way of canceling
runBlocking
? I’m bridging a blocking API that gives me a
CancelationSignal
that can notify when canceled
Seems like I can cancel the context as normal, there used to be an issue with this: https://github.com/Kotlin/kotlinx.coroutines/issues/586
But it has since been fixed
g

groostav

03/13/2019, 10:53 PM
Sorry, so did you find what you were looking for? Out of curiosity, whats the result from the
runBlocking
, did you get it to throw a
CancellationException
? or does it use java-1-5 "interruption" flag & exception?
a

ansman

03/13/2019, 10:54 PM
Yes, this throws a
CancellationException
as expected:
runBlocking {
    coroutineContext.cancel()
}