-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Bug or misuse? Exceptions not propagating through multithreaded channels #34262
Comments
Sorry, forgot the version info:
|
I think this is a dup of #32677. A possible solution is @sync begin
@async try
@sync for i in 1:10
Threads.@spawn put!(channel, work(i))
end
finally
close(channel)
end
@async for i in 1:10
println(take!(channel))
end
end I think we need structured concurrency #33248 to get rid of this kind of problem. |
Also, see #34198 |
Could be. I didn't find it in a pre-submit search as I was focused on the threading instead of the tasking. The conversation in that thread is focused on the task, by the way, but I think the issue (common to both threads) is the Channel. I already had an original (not-heavily-tested) solution without Channels and I was trying to upgrade to Channels when I ran across this. (The main issue with my original solution was that it was more complex and required some "load balancing" in thread 1, which gets less effective when the scheduler tosses a heavy-load task onto the same thread.) I'll try to see if an MWE of my original solution, mapped to the same test case above, sheds any light. |
Okay, here is an MWE of my original solution (kind of), using the same error-generating
|
@KristofferC , from #34198:
You're right - that does sound pretty related... |
Your OP example has the same bug if you replace |
Sold. I’ll close this and watch the other. |
In the following code, one task throws an error that does not propagate to terminate the whole routine. But the task itself ends and never produces a result for the Channel, so the receiver waits forever for the last result. Is this an error in the exception handling or a flagrant violation of channel / thread usage in some way?
The text was updated successfully, but these errors were encountered: