From e4559fd98e1c2b71448a7656223f9674b3b2bad5 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:23:08 +0100 Subject: [PATCH 1/3] Throw an error in `checktask` when a task failed --- src/threadtasks.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/threadtasks.jl b/src/threadtasks.jl index 4e8c272..668ed31 100644 --- a/src/threadtasks.jl +++ b/src/threadtasks.jl @@ -71,7 +71,7 @@ end t = TASKS[tid] if istaskfailed(t) initialize_task(tid) - return true + throw(TaskFailedException(t)) end yield() false @@ -90,4 +90,3 @@ end end false end - From d580f9e3ce29a38c81db43da7e4bb78c0af159c2 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:49:01 +0200 Subject: [PATCH 2/3] Fix tests --- test/threadingutilities.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/threadingutilities.jl b/test/threadingutilities.jl index bb43d74..7acf6b6 100644 --- a/test/threadingutilities.jl +++ b/test/threadingutilities.jl @@ -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 "This function throws if N == 0 for testing purposes." 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 - From 8884d9ec6dc685d4c0dce1e08d4bec46d321ca50 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 7 Apr 2025 12:19:04 +0200 Subject: [PATCH 3/3] Try to fix tests with Julia 1.5 --- test/threadingutilities.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/threadingutilities.jl b/test/threadingutilities.jl index 7acf6b6..719e867 100644 --- a/test/threadingutilities.jl +++ b/test/threadingutilities.jl @@ -85,7 +85,7 @@ end @test all(istaskfailed, ThreadingUtilities.TASKS) # Test that `wait` reports the error for each task for tid in eachindex(ThreadingUtilities.TASKS) - @test_throws "This function throws if N == 0 for testing purposes." ThreadingUtilities.wait(tid) + @test_throws TaskFailedException ThreadingUtilities.wait(tid) end # Test that none of the tasks are in the failed state @test !any(istaskfailed, ThreadingUtilities.TASKS)