Skip to content

Commit 6bc14e5

Browse files
committed
Avoid returning data from Julia tasks
To avoid JuliaLang/julia#40626
1 parent 64acec0 commit 6bc14e5

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/sch/Sch.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ function fire_tasks!(ctx, thunks::Vector{<:Tuple}, (gproc, proc), state)
10631063
@async begin
10641064
timespan_start(ctx, :fire, gproc.pid, 0)
10651065
try
1066-
remotecall_wait(do_tasks, gproc.pid, proc, state.chan, [ts])
1066+
remotecall_wait(do_tasks, gproc.pid, proc, state.chan, [ts]);
10671067
catch err
10681068
bt = catch_backtrace()
10691069
thunk_id = ts[1]

src/threadproc.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,25 @@ iscompatible_func(proc::ThreadProc, opts, f) = true
1212
iscompatible_arg(proc::ThreadProc, opts, x) = true
1313
function execute!(proc::ThreadProc, @nospecialize(f), @nospecialize(args...); @nospecialize(kwargs...))
1414
tls = get_tls()
15+
# FIXME: Use return type of the call to specialize container
16+
result = Ref{Any}()
1517
task = Task() do
1618
set_tls!(tls)
1719
TimespanLogging.prof_task_put!(tls.sch_handle.thunk_id.id)
18-
@invokelatest f(args...; kwargs...)
20+
result[] = @invokelatest f(args...; kwargs...)
21+
return
1922
end
2023
set_task_tid!(task, proc.tid)
2124
schedule(task)
2225
try
2326
fetch(task)
27+
return result[]
2428
catch err
25-
@static if VERSION < v"1.7-rc1"
26-
stk = Base.catch_stack(task)
27-
else
28-
stk = Base.current_exceptions(task)
29-
end
30-
err, frames = stk[1]
29+
err, frames = Base.current_exceptions(task)[1]
3130
rethrow(CapturedException(err, frames))
3231
end
3332
end
3433
get_parent(proc::ThreadProc) = OSProc(proc.owner)
3534
default_enabled(proc::ThreadProc) = true
3635

3736
# TODO: ThreadGroupProc?
38-

0 commit comments

Comments
 (0)