Skip to content

Commit c65df04

Browse files
authored
Merge pull request JuliaLang/julia#32270 from JuliaLang/backports-1.2.0-rc2
Backports 1.2.0 rc2
2 parents de67bc1 + 76f3418 commit c65df04

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

src/macros.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Equivalent to calling `remotecall_eval(Main, procs, expr)`.
172172
"""
173173
macro everywhere(ex)
174174
procs = GlobalRef(@__MODULE__, :procs)
175-
return esc(:(@everywhere $procs() $ex))
175+
return esc(:($(Distributed).@everywhere $procs() $ex))
176176
end
177177

178178
macro everywhere(procs, ex)

src/pmap.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,11 @@ Return `head`: the first `n` elements of `c`;
238238
and `tail`: an iterator over the remaining elements.
239239
240240
```jldoctest
241-
julia> a = 1:10
242-
1:10
243-
244-
julia> b, c = Base.head_and_tail(a, 3)
245-
([1,2,3],Base.Iterators.Rest{UnitRange{Int64},Int64}(1:10,4))
241+
julia> b, c = Distributed.head_and_tail(1:10, 3)
242+
([1, 2, 3], Base.Iterators.Rest{UnitRange{Int64},Int64}(1:10, 3))
246243
247244
julia> collect(c)
248-
7-element Array{Any,1}:
245+
7-element Array{Int64,1}:
249246
4
250247
5
251248
6
@@ -268,7 +265,7 @@ function head_and_tail(c, n)
268265
i += 1
269266
head[i] = y[1]
270267
end
271-
return head, Iterators.rest(c, s)
268+
return head, Iterators.rest(c, y[2])
272269
end
273270

274271
"""

test/distributed_exec.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,44 @@ for T in (UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64)
16141614
@test n == 55
16151615
end
16161616

1617+
# issue #28966
1618+
let code = """
1619+
import Distributed
1620+
Distributed.addprocs(1)
1621+
Distributed.@everywhere f() = myid()
1622+
for w in Distributed.workers()
1623+
@assert Distributed.remotecall_fetch(f, w) == w
1624+
end
1625+
"""
1626+
@test success(`$(Base.julia_cmd()) --startup-file=no -e $code`)
1627+
end
1628+
1629+
# PR 32431: tests for internal Distributed.head_and_tail
1630+
let (h, t) = Distributed.head_and_tail(1:10, 3)
1631+
@test h == 1:3
1632+
@test collect(t) == 4:10
1633+
end
1634+
let (h, t) = Distributed.head_and_tail(1:10, 0)
1635+
@test h == []
1636+
@test collect(t) == 1:10
1637+
end
1638+
let (h, t) = Distributed.head_and_tail(1:3, 5)
1639+
@test h == 1:3
1640+
@test collect(t) == []
1641+
end
1642+
let (h, t) = Distributed.head_and_tail(1:3, 3)
1643+
@test h == 1:3
1644+
@test collect(t) == []
1645+
end
1646+
let (h, t) = Distributed.head_and_tail(Int[], 3)
1647+
@test h == []
1648+
@test collect(t) == []
1649+
end
1650+
let (h, t) = Distributed.head_and_tail(Int[], 0)
1651+
@test h == []
1652+
@test collect(t) == []
1653+
end
1654+
16171655
# Run topology tests last after removing all workers, since a given
16181656
# cluster at any time only supports a single topology.
16191657
rmprocs(workers())

0 commit comments

Comments
 (0)