Skip to content

Commit

Permalink
Fix RemoteChannel iterator interface
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwe committed Apr 10, 2024
1 parent 3b889ee commit c846b0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/remotecall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -797,4 +797,4 @@ function iterate(c::RemoteChannel, state=nothing)
end
end

IteratorSize(::Type{<:RemoteChannel}) = SizeUnknown()
IteratorSize(::Type{<:RemoteChannel}) = Base.SizeUnknown()
8 changes: 8 additions & 0 deletions test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ test_iteration(RemoteChannel(() -> Channel(10)), RemoteChannel(() -> Channel(10)
return count
end

@everywhere test_iteration_collect(ch) = length(collect(ch))

@everywhere function test_iteration_put(ch, total)
for i in 1:total
put!(ch, i)
Expand All @@ -483,10 +485,16 @@ end
let ch = RemoteChannel(() -> Channel(1))
@async test_iteration_put(ch, 10)
@test 10 == @fetchfrom id_other test_iteration_take(ch)
ch = RemoteChannel(() -> Channel(1))
@async test_iteration_put(ch, 10)
@test 10 == @fetchfrom id_other test_iteration_collect(ch)
# now reverse
ch = RemoteChannel(() -> Channel(1))
@spawnat id_other test_iteration_put(ch, 10)
@test 10 == test_iteration_take(ch)
ch = RemoteChannel(() -> Channel(1))
@spawnat id_other test_iteration_put(ch, 10)
@test 10 == test_iteration_collect(ch)
end

# make sure exceptions propagate when waiting on Tasks
Expand Down

0 comments on commit c846b0e

Please sign in to comment.