Skip to content

Commit efa47b0

Browse files
author
KDr2
committed
check task status
1 parent 9bd2b06 commit efa47b0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/tapedtask.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ function consume(ttask::TapedTask)
7070
val = try
7171
take!(ttask.produce_ch)
7272
catch e
73-
# return nothing to indicate the finish of the task
74-
isa(e, InvalidStateException) ? nothing : rethrow()
73+
isa(e, InvalidStateException) || rethrow()
74+
istaskfailed(ttask.task) && throw(ttask.task.exception)
75+
# TODO: we return nothing to indicate the end of a task,
76+
# remove this when AdvancedPS is udpated.
77+
istaskdone(ttask.task) && return nothing
7578
end
79+
80+
# yield to let the task resume, this is necessary when there's
81+
# an exception is thrown in the task, it gives the task the chance
82+
# to rethow the exception and set its proper status:
7683
yield()
7784
isa(val, TapedTaskException) && throw(val.exc)
7885
return val

0 commit comments

Comments
 (0)