Skip to content

Commit

Permalink
Merge pull request JuliaLang/julia#32270 from JuliaLang/backports-1.2…
Browse files Browse the repository at this point in the history
….0-rc2

Backports 1.2.0 rc2
  • Loading branch information
ararslan authored Jul 8, 2019
2 parents de67bc1 + 76f3418 commit c65df04
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Equivalent to calling `remotecall_eval(Main, procs, expr)`.
"""
macro everywhere(ex)
procs = GlobalRef(@__MODULE__, :procs)
return esc(:(@everywhere $procs() $ex))
return esc(:($(Distributed).@everywhere $procs() $ex))
end

macro everywhere(procs, ex)
Expand Down
11 changes: 4 additions & 7 deletions src/pmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,11 @@ Return `head`: the first `n` elements of `c`;
and `tail`: an iterator over the remaining elements.
```jldoctest
julia> a = 1:10
1:10
julia> b, c = Base.head_and_tail(a, 3)
([1,2,3],Base.Iterators.Rest{UnitRange{Int64},Int64}(1:10,4))
julia> b, c = Distributed.head_and_tail(1:10, 3)
([1, 2, 3], Base.Iterators.Rest{UnitRange{Int64},Int64}(1:10, 3))
julia> collect(c)
7-element Array{Any,1}:
7-element Array{Int64,1}:
4
5
6
Expand All @@ -268,7 +265,7 @@ function head_and_tail(c, n)
i += 1
head[i] = y[1]
end
return head, Iterators.rest(c, s)
return head, Iterators.rest(c, y[2])
end

"""
Expand Down
38 changes: 38 additions & 0 deletions test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,44 @@ for T in (UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64)
@test n == 55
end

# issue #28966
let code = """
import Distributed
Distributed.addprocs(1)
Distributed.@everywhere f() = myid()
for w in Distributed.workers()
@assert Distributed.remotecall_fetch(f, w) == w
end
"""
@test success(`$(Base.julia_cmd()) --startup-file=no -e $code`)
end

# PR 32431: tests for internal Distributed.head_and_tail
let (h, t) = Distributed.head_and_tail(1:10, 3)
@test h == 1:3
@test collect(t) == 4:10
end
let (h, t) = Distributed.head_and_tail(1:10, 0)
@test h == []
@test collect(t) == 1:10
end
let (h, t) = Distributed.head_and_tail(1:3, 5)
@test h == 1:3
@test collect(t) == []
end
let (h, t) = Distributed.head_and_tail(1:3, 3)
@test h == 1:3
@test collect(t) == []
end
let (h, t) = Distributed.head_and_tail(Int[], 3)
@test h == []
@test collect(t) == []
end
let (h, t) = Distributed.head_and_tail(Int[], 0)
@test h == []
@test collect(t) == []
end

# Run topology tests last after removing all workers, since a given
# cluster at any time only supports a single topology.
rmprocs(workers())
Expand Down

0 comments on commit c65df04

Please sign in to comment.