What’s the idiomatic way of canceling `runBlocking...
# coroutines
a
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
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
Yes, this throws a
CancellationException
as expected:
Copy code
runBlocking {
    coroutineContext.cancel()
}