-
-
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
Make RemoteChannel iterable #33555
Make RemoteChannel iterable #33555
Conversation
bump 🙂 |
Seems like something we should clearly do. The only issue is the implementation. Does this approach seem good to you, @JeffBezanson? |
Is this ready to go, @tkf? |
try | ||
return (take!(c), nothing) | ||
catch e | ||
if isa(e, InvalidStateException) && e.state == :closed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isa(e, InvalidStateException)
is not enough.
We'd need to handle the case when the channel is a reference
julia> ch = RemoteChannel(workers()[end])
RemoteChannel{Channel{Any}}(2, 1, 8)
julia> put!(ch, 1)
RemoteChannel{Channel{Any}}(2, 1, 8)
julia> close(ch)
julia> take!(ch)
1
julia> err = try
take!(ch)
catch err
err
end
RemoteException(2, CapturedException(InvalidStateException("Channel is closed.", :closed), Any[(check_channel_state at channels.jl:170 [inlined], 1), (take_buffered at channels.jl:388, 1), (take! at channels.jl:383, 1), (take! at remotecall.jl:599,
1), (take_ref at remotecall.jl:610, 1), (#106 at process_messages.jl:278, 1), (run_work_thunk at process_messages.jl:63, 1)
, (macro expansion at process_messages.jl:278 [inlined], 1), (#105 at task.jl:411, 1)]))
#41966 is an alternative solution to this |
Replaced by (included in) #41966 |
Being an iterator is one of the nice features of Channel. Can RemoteChannel have it?
close #31177