-
-
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
Error Handling in Tasks #32677
Comments
This is likely due to the fact that we wait in order on the tasks, instead of peeking if one has errored. edit: In Go there is |
go That seems like a better default behavior for @sync cancellation=foo begin
@async f1()
@async f2()
end though I'm not sure what kind of thing |
cc @tkf who has looked into cancellation and Trio-style structured I/O a bit already. |
It looks like the problem here is that the code in the OP is mixing two synchronization paradigms (structured concurrency ( @sync begin
c = @Channel(0)
...do stuff...
end which is expanded to let tasks = [], # we call it `sync_varname` now
channels = []
ans = begin
c = Channel(0)
push!(channels, c)
...do stuff...
end
Base.sync_end(tasks, channels)
ans
end (Or maybe use In Of course, closeing channels is not ideal because it makes error handling hard; you have to distinguish errors due to the automatic maybe_take!(c::Channel{T}) :: Union{Some{T}, Cancelled}
maybe_put!(c::Channel) :: Union{Nothing, Cancelled} where y = @await maybe_take!(c) expands to x = maybe_take!(c)
x isa Cancelled && return x
x = something(y) This way, you can create a convention that (A more sophisticated version of |
Is this issue on the drawing board for 1.6 or further in the future? I'd be happy to help here over the holidays, if needed. |
The 1.6 release is branching right about now so no more features. If you want to work on this for 1.7 though, that would be great. |
…ntee exceptions propagate upward
@StefanKarpinski - so I have a fix for this (way simplified from the above), based on parallelizing Would it make more sense to issue a PR into Experimental, or directly into task.jl? Or is this considered too delicate a PR for a non-core developer (I won't take offense)? |
So after wandering down a few different paths and getting feedback on #38916 and #38992, I came to the conclusion that the solution to this problem was (an inferior implementation of) what is already in |
Hi this is a bit over my head, but I tried it both ways round today on Julia 1.6.2 and it errored both times. `
ERROR: TaskFailedException
...and 1 more exception. Stacktrace: ` ` julia> @sync begin
ERROR: TaskFailedException
...and 1 more exception. Stacktrace: ` |
Seems this is now |
Not sure if this is an extension of #10405 or a novel issue, but the following example provides two tasks, one of which will throw an error, the other is blocking. This makes async code difficult to debug.
Interestingly, reversing the @async blocks will cause the error to propagate properly.
I've verified this is the case in 1.1.0 and 1.3.0-alpha
The text was updated successfully, but these errors were encountered: