Skip to content

Commit 72ca9ca

Browse files
authored
If a task returns an exception value, do not raise it in #wait. (#270)
1 parent 7773705 commit 72ca9ca

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/async/task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def wait
190190
@finished.wait
191191
end
192192

193-
if @result.is_a?(Exception)
193+
if @status == :failed
194194
raise @result
195195
else
196196
return @result

test/async/task.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,13 @@ def sleep_forever
711711
expect(error_task).to be(:finished?)
712712
expect(innocent_task).to be(:finished?)
713713
end
714+
715+
it "will not raise exception values returned by the task" do
716+
error = StandardError.new
717+
task = reactor.async { error }
718+
expect(task.wait).to be == error
719+
expect(task.result).to be == error
720+
end
714721
end
715722

716723
with '#result' do

0 commit comments

Comments
 (0)