-
Notifications
You must be signed in to change notification settings - Fork 1.9k
The source channel is not cancelled when cancelling the result of produce(onCompletion = consumes())
#407
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
Comments
It should hang. So your code is roughly equivalent to
|
Thanks @qwwdfsad for your help. However, I don't understand why it should hang. If Consider this new code: fun main(args: Array<String>) = runBlocking<Unit> {
val source = Channel<Int>()
println("start an unconfined produce job")
val produced = produce<Int>(Unconfined, onCompletion = source.consumes()) {
println("produce job started")
try {
source.receive()
} catch (t: Throwable) {
println("job failed") // cancel should make fail [receive] right here, in the current call frame
}
}
println("cancel job")
produced.cancel()
println("job cancelled")
try {
source.receive()
} catch (t: Throwable) {
println("receive from source failed")
}
} Because of the
But I have:
|
Thanks for the clarification, I've misread a problem. I'll try to comment your code to make a problem more obvious:
|
That's the point. My understanding is: Because I used
|
By the way why does this code produce a fun main(args: Array<String>) = runBlocking<Unit> {
val source = Channel<Int>()
val produced = produce<Int>(Unconfined, onCompletion = source.consumes()) {
source.receive()
}
produced.cancel()
} |
Thanks for your report. |
Thank you again for the report, your issue revealed even bigger problem which may cause unexpected non-determinism (and probably heisenbugs with "Exception in completion handler") in programs without I described it under #415 and will fix it there |
The following test hangs:
I would expect the test to pass.
The text was updated successfully, but these errors were encountered: