Closed
Description
I have this simple flow
runBlocking(Dispatchers.Default) {
channelFlow {
val j = launch {
delay(10000000)
}
var i = 0
while (true) {
delay(1000)
send(i++)
if (i == 3) j.cancelAndJoin()
}
}.collect {
println("received: $it")
}
}
Actual result:
received: 0
received: 1
received: 2
Exception in thread "main" kotlinx.coroutines.JobCancellationException: Job was cancelled; job=StandaloneCoroutine{Cancelled}@185d8b6
I expected to cancel launched coroutine but looks like it also cancels channelFlow.
@qwwdfsad, Is it right behaviour ?