Skip to content

Throw an error in checktask when a task failed #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/threadtasks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ end
t = TASKS[tid]
if istaskfailed(t)
initialize_task(tid)
return true
throw(TaskFailedException(t))
end
yield()
false
Expand All @@ -90,4 +90,3 @@ end
end
false
end

8 changes: 6 additions & 2 deletions test/threadingutilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,18 @@ end
@test ThreadingUtilities.load(pointer(x), ThreadingUtilities.ThreadState) ==
ThreadingUtilities.SPIN
end
# Make all tasks error
for tid ∈ eachindex(ThreadingUtilities.TASKS)
launch_thread_copy!(tid, Float64[], Float64[])
end
sleep(1)
@test all(istaskfailed, ThreadingUtilities.TASKS)
@test all(ThreadingUtilities.wait, eachindex(ThreadingUtilities.TASKS))
# Test that `wait` reports the error for each task
for tid in eachindex(ThreadingUtilities.TASKS)
@test_throws TaskFailedException ThreadingUtilities.wait(tid)
end
# Test that none of the tasks are in the failed state
@test !any(istaskfailed, ThreadingUtilities.TASKS)
# test copy on the reinitialized tasks
foreach(test_copy, eachindex(ThreadingUtilities.TASKS))
end

Loading