Skip to content

Commit 142ab6c

Browse files
authored
Throw an error in checktask when a task failed (#54)
* Throw an error in `checktask` when a task failed * Fix tests * Try to fix tests with Julia 1.5
1 parent e867205 commit 142ab6c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/threadtasks.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ end
7171
t = TASKS[tid]
7272
if istaskfailed(t)
7373
initialize_task(tid)
74-
return true
74+
throw(TaskFailedException(t))
7575
end
7676
yield()
7777
false
@@ -90,4 +90,3 @@ end
9090
end
9191
false
9292
end
93-

test/threadingutilities.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ end
7777
@test ThreadingUtilities.load(pointer(x), ThreadingUtilities.ThreadState) ==
7878
ThreadingUtilities.SPIN
7979
end
80+
# Make all tasks error
8081
for tid eachindex(ThreadingUtilities.TASKS)
8182
launch_thread_copy!(tid, Float64[], Float64[])
8283
end
8384
sleep(1)
8485
@test all(istaskfailed, ThreadingUtilities.TASKS)
85-
@test all(ThreadingUtilities.wait, eachindex(ThreadingUtilities.TASKS))
86+
# Test that `wait` reports the error for each task
87+
for tid in eachindex(ThreadingUtilities.TASKS)
88+
@test_throws TaskFailedException ThreadingUtilities.wait(tid)
89+
end
90+
# Test that none of the tasks are in the failed state
8691
@test !any(istaskfailed, ThreadingUtilities.TASKS)
8792
# test copy on the reinitialized tasks
8893
foreach(test_copy, eachindex(ThreadingUtilities.TASKS))
8994
end
90-

0 commit comments

Comments
 (0)