Skip to content

Conversation

@JamesWrigley
Copy link
Member

The default method from Base has the nasty side-effect of take!()'ing from the underlying channel.

The default method from Base has the nasty side-effect of take!()'ing from the
underlying channel.
@codecov
Copy link

codecov bot commented Aug 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.18%. Comparing base (729ba6a) to head (8b5983b).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
+ Coverage   79.16%   79.18%   +0.02%     
==========================================
  Files          10       10              
  Lines        1896     1898       +2     
==========================================
+ Hits         1501     1503       +2     
  Misses        395      395              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JamesWrigley
Copy link
Member Author

(bump)

3 similar comments
@JamesWrigley
Copy link
Member Author

(bump)

@JamesWrigley
Copy link
Member Author

(bump)

@JamesWrigley
Copy link
Member Author

(bump)

Copy link
Member

@LilithHafner LilithHafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes isempty return true instead of hanging when the channel is empty.

@JamesWrigley
Copy link
Member Author

This also makes isempty return false instead of hanging when the channel is empty.

Huh?

julia> using Distributed

julia> addprocs(1)
1-element Vector{Int64}:
 2

julia> x = RemoteChannel()
RemoteChannel{Channel{Any}}(1, 1, 3)

julia> remotecall_fetch(isempty, 2, x)
true

@LilithHafner
Copy link
Member

Huh. That's weird.

Screencast.from.2024-11-16.16-29-17.webm

@LilithHafner
Copy link
Member

And when I interrupt

julia> remotecall_fetch(isempty, 2, x)
^CERROR: InterruptException:
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base ./task.jl:958
  [2] wait()
    @ Base ./task.jl:1022
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base ./condition.jl:130
  [4] wait
    @ ./condition.jl:125 [inlined]
  [5] take_buffered(c::Channel{Any})
    @ Base ./channels.jl:493
  [6] take!(c::Channel{Any})
    @ Base ./channels.jl:487
  [7] take!(::Distributed.RemoteValue)
    @ Distributed ~/.julia/juliaup/julia-1.11.1+0.aarch64.linux.gnu/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:726
  [8] remotecall_fetch(f::Function, w::Distributed.Worker, args::RemoteChannel{Channel{Any}}; kwargs::@Kwargs{})
    @ Distributed ~/.julia/juliaup/julia-1.11.1+0.aarch64.linux.gnu/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:461
  [9] remotecall_fetch(f::Function, w::Distributed.Worker, args::RemoteChannel{Channel{Any}})
    @ Distributed ~/.julia/juliaup/julia-1.11.1+0.aarch64.linux.gnu/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:454
 [10] remotecall_fetch(f::Function, id::Int64, args::RemoteChannel{Channel{Any}})
    @ Distributed ~/.julia/juliaup/julia-1.11.1+0.aarch64.linux.gnu/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:492
 [11] top-level scope
    @ REPL[5]:1

@JamesWrigley
Copy link
Member Author

To clarify, in my code snippet I started Julia with julia --project to use this branch. I still don't understand how you saw isempty() return false?

@LilithHafner
Copy link
Member

I still don't understand how you saw isempty() return false?

I miss spoke. It correctly returns true when the collection is empty.

Copy link
Member

@LilithHafner LilithHafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ViralBShah
Copy link
Member

@JamesWrigley I have invited you to have commit access to the repo. Thanks for the PRs!

@JamesWrigley
Copy link
Member Author

Cool, thanks :)

@JamesWrigley JamesWrigley merged commit ed12496 into JuliaLang:master Dec 2, 2024
8 checks passed
@JamesWrigley JamesWrigley deleted the remotechannel-empty branch December 2, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants