Skip to content

Commit 8a86e37

Browse files
committed
Make on_main_thread test more reliable
1 parent 30f0612 commit 8a86e37

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/Core.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,9 @@ end
838838
end
839839

840840
@testitem "on_main_thread" begin
841-
task = Threads.@spawn PythonCall.C.on_main_thread() do; Threads.threadid(); end
842-
@test fetch(task) == 1
841+
refid = PythonCall.C.on_main_thread() do; Threads.threadid(); end
842+
tasks = [Threads.@spawn(PythonCall.C.on_main_thread() do; Threads.threadid(); end) for _ in 1:20]
843+
@test all(t -> fetch(t) == refid, tasks)
843844
@test_throws DivideError redirect_stderr(devnull) do
844845
PythonCall.C.on_main_thread() do
845846
throw(DivideError())

0 commit comments

Comments
 (0)