Skip to content

Commit 4d1bf0b

Browse files
authored
Merge pull request #43398 from krynju/kr/distributed-remote-fetch-fix
[Distributed] Return value obtained from `call_on_owner` directly
2 parents 524bca4 + 4b97df7 commit 4d1bf0b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

stdlib/Distributed/src/remotecall.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,15 @@ function fetch(r::Future)
631631
# why? local put! performs caching and putting into channel under r.lock
632632

633633
# for local put! use the cached value, for call_on_owner cases just take the v_local as it was just cached in r.v
634-
v_cache = status ? v_local : v_old
634+
635+
# remote calls getting the value from `call_on_owner` used to return the value directly without wrapping it in `Some(x)`
636+
# so we're doing the same thing here
637+
if status
638+
send_del_client(r)
639+
return v_local
640+
else # this `v_cache` is returned at the end of the function
641+
v_cache = v_old
642+
end
635643
end
636644

637645
send_del_client(r)

stdlib/Distributed/test/distributed_exec.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,16 @@ v15406 = remotecall_wait(() -> 1, id_other)
841841
fetch(v15406)
842842
remotecall_wait(fetch, id_other, v15406)
843843

844+
845+
# issue #43396
846+
# Covers the remote fetch where the value returned is `nothing`
847+
# May be caused by attempting to unwrap a non-`Some` type with `something`
848+
# `call_on_owner` ref fetches return values not wrapped in `Some`
849+
# and have to be returned directly
850+
@test nothing === fetch(remotecall(() -> nothing, workers()[1]))
851+
@test 10 === fetch(remotecall(() -> 10, workers()[1]))
852+
853+
844854
# Test various forms of remotecall* invocations
845855

846856
@everywhere f_args(v1, v2=0; kw1=0, kw2=0) = v1+v2+kw1+kw2

0 commit comments

Comments
 (0)